diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..50a4c7b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,29 @@ +--- +name: Bug Report +about: Create a report to help us improve +title: "fix: " +labels: bug +--- + +**Description** + +A clear and concise description of what the bug is. + +**Steps To Reproduce** + +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected Behavior** + +A clear and concise description of what you expected to happen. + +**Screenshots** + +If applicable, add screenshots to help explain your problem. + +**Additional Context** + +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/build.md b/.github/ISSUE_TEMPLATE/build.md new file mode 100644 index 0000000..0cf8e62 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/build.md @@ -0,0 +1,14 @@ +--- +name: Build System +about: Changes that affect the build system or external dependencies +title: "build: " +labels: build +--- + +**Description** + +Describe what changes need to be done to the build system and why. + +**Requirements** + +- [ ] The build system is passing diff --git a/.github/ISSUE_TEMPLATE/chore.md b/.github/ISSUE_TEMPLATE/chore.md new file mode 100644 index 0000000..498ebfd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/chore.md @@ -0,0 +1,14 @@ +--- +name: Chore +about: Other changes that don't modify src or test files +title: "chore: " +labels: chore +--- + +**Description** + +Clearly describe what change is needed and why. If this changes code then please use another issue type. + +**Requirements** + +- [ ] No functional changes to the code diff --git a/.github/ISSUE_TEMPLATE/ci.md b/.github/ISSUE_TEMPLATE/ci.md new file mode 100644 index 0000000..fa2dd9e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/ci.md @@ -0,0 +1,14 @@ +--- +name: Continuous Integration +about: Changes to the CI configuration files and scripts +title: "ci: " +labels: ci +--- + +**Description** + +Describe what changes need to be done to the ci/cd system and why. + +**Requirements** + +- [ ] The ci system is passing diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..ec4bb38 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/documentation.md b/.github/ISSUE_TEMPLATE/documentation.md new file mode 100644 index 0000000..f494a4d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation.md @@ -0,0 +1,14 @@ +--- +name: Documentation +about: Improve the documentation so all collaborators have a common understanding +title: "docs: " +labels: documentation +--- + +**Description** + +Clearly describe what documentation you are looking to add or improve. + +**Requirements** + +- [ ] Requirements go here diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..ddd2fcc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,18 @@ +--- +name: Feature Request +about: A new feature to be added to the project +title: "feat: " +labels: feature +--- + +**Description** + +Clearly describe what you are looking to add. The more context the better. + +**Requirements** + +- [ ] Checklist of requirements to be fulfilled + +**Additional Context** + +Add any other context or screenshots about the feature request go here. diff --git a/.github/ISSUE_TEMPLATE/performance.md b/.github/ISSUE_TEMPLATE/performance.md new file mode 100644 index 0000000..699b8d4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/performance.md @@ -0,0 +1,14 @@ +--- +name: Performance Update +about: A code change that improves performance +title: "perf: " +labels: performance +--- + +**Description** + +Clearly describe what code needs to be changed and what the performance impact is going to be. Bonus point's if you can tie this directly to user experience. + +**Requirements** + +- [ ] There is no drop in test coverage. diff --git a/.github/ISSUE_TEMPLATE/refactor.md b/.github/ISSUE_TEMPLATE/refactor.md new file mode 100644 index 0000000..1626c57 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/refactor.md @@ -0,0 +1,14 @@ +--- +name: Refactor +about: A code change that neither fixes a bug nor adds a feature +title: "refactor: " +labels: refactor +--- + +**Description** + +Clearly describe what needs to be refactored and why. Please provide links to related issues (bugs or upcoming features) in order to help prioritize. + +**Requirements** + +- [ ] There is no drop in test coverage. diff --git a/.github/ISSUE_TEMPLATE/revert.md b/.github/ISSUE_TEMPLATE/revert.md new file mode 100644 index 0000000..9d121dc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/revert.md @@ -0,0 +1,16 @@ +--- +name: Revert Commit +about: Reverts a previous commit +title: "revert: " +labels: revert +--- + +**Description** + +Provide a link to a PR/Commit that you are looking to revert and why. + +**Requirements** + +- [ ] Change has been reverted +- [ ] No change in test coverage has happened +- [ ] A new ticket is created for any follow on work that needs to happen diff --git a/.github/ISSUE_TEMPLATE/style.md b/.github/ISSUE_TEMPLATE/style.md new file mode 100644 index 0000000..02244a7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/style.md @@ -0,0 +1,14 @@ +--- +name: Style Changes +about: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc) +title: "style: " +labels: style +--- + +**Description** + +Clearly describe what you are looking to change and why. + +**Requirements** + +- [ ] There is no drop in test coverage. diff --git a/.github/ISSUE_TEMPLATE/test.md b/.github/ISSUE_TEMPLATE/test.md new file mode 100644 index 0000000..431a7ea --- /dev/null +++ b/.github/ISSUE_TEMPLATE/test.md @@ -0,0 +1,14 @@ +--- +name: Test +about: Adding missing tests or correcting existing tests +title: "test: " +labels: test +--- + +**Description** + +List out the tests that need to be added or changed. Please also include any information as to why this was not covered in the past. + +**Requirements** + +- [ ] There is no drop in test coverage. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..1169936 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,27 @@ + + +## Status + +**READY/IN DEVELOPMENT/HOLD** + +## Description + + + +## Type of Change + + + +- [ ] โœจ New feature (non-breaking change which adds functionality) +- [ ] ๐Ÿ› ๏ธ Bug fix (non-breaking change which fixes an issue) +- [ ] โŒ Breaking change (fix or feature that would cause existing functionality to change) +- [ ] ๐Ÿงน Code refactor +- [ ] โœ… Build configuration change +- [ ] ๐Ÿ“ Documentation +- [ ] ๐Ÿ—‘๏ธ Chore diff --git a/.github/cspell.json b/.github/cspell.json new file mode 100644 index 0000000..11525a1 --- /dev/null +++ b/.github/cspell.json @@ -0,0 +1,21 @@ +{ + "version": "0.2", + "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json", + "dictionaries": ["vgv_allowed", "vgv_forbidden"], + "dictionaryDefinitions": [ + { + "name": "vgv_allowed", + "path": "https://raw.githubusercontent.com/verygoodopensource/very_good_dictionaries/main/allowed.txt", + "description": "Allowed VGV Spellings" + }, + { + "name": "vgv_forbidden", + "path": "https://raw.githubusercontent.com/verygoodopensource/very_good_dictionaries/main/forbidden.txt", + "description": "Forbidden VGV Spellings" + } + ], + "useGitignore": true, + "words": [ + "instantly_sdk" + ] +} diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..63b035c --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,11 @@ +version: 2 +enable-beta-ecosystems: true +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + - package-ecosystem: "pub" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..c7146c3 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,27 @@ +name: ci + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + semantic_pull_request: + uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/semantic_pull_request.yml@v1 + + spell-check: + uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/spell_check.yml@v1 + with: + includes: "**/*.md" + modified_files_only: false + + build: + uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1 + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..526da15 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +# See https://www.dartlang.org/guides/libraries/private-files + +# Files and directories created by pub +.dart_tool/ +.packages +build/ +pubspec.lock \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..78bd725 --- /dev/null +++ b/README.md @@ -0,0 +1,62 @@ +# Instantly Sdk + +[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link] +[![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason) +[![License: MIT][license_badge]][license_link] + +A Very Good Project created by Very Good CLI. + +## Installation ๐Ÿ’ป + +**โ— In order to start using Instantly Sdk you must have the [Dart SDK][dart_install_link] installed on your machine.** + +Install via `dart pub add`: + +```sh +dart pub add instantly_sdk +``` + +--- + +## Continuous Integration ๐Ÿค– + +Instantly Sdk comes with a built-in [GitHub Actions workflow][github_actions_link] powered by [Very Good Workflows][very_good_workflows_link] but you can also add your preferred CI/CD solution. + +Out of the box, on each pull request and push, the CI `formats`, `lints`, and `tests` the code. This ensures the code remains consistent and behaves correctly as you add functionality or make changes. The project uses [Very Good Analysis][very_good_analysis_link] for a strict set of analysis options used by our team. Code coverage is enforced using the [Very Good Workflows][very_good_coverage_link]. + +--- + +## Running Tests ๐Ÿงช + +To run all unit tests: + +```sh +dart pub global activate coverage 1.2.0 +dart test --coverage=coverage +dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info +``` + +To view the generated coverage report you can use [lcov](https://github.com/linux-test-project/lcov). + +```sh +# Generate Coverage Report +genhtml coverage/lcov.info -o coverage/ + +# Open Coverage Report +open coverage/index.html +``` + +[dart_install_link]: https://dart.dev/get-dart +[github_actions_link]: https://docs.github.com/en/actions/learn-github-actions +[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg +[license_link]: https://opensource.org/licenses/MIT +[logo_black]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_black.png#gh-light-mode-only +[logo_white]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_white.png#gh-dark-mode-only +[mason_link]: https://github.com/felangel/mason +[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg +[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis +[very_good_coverage_link]: https://github.com/marketplace/actions/very-good-coverage +[very_good_ventures_link]: https://verygood.ventures +[very_good_ventures_link_light]: https://verygood.ventures#gh-light-mode-only +[very_good_ventures_link_dark]: https://verygood.ventures#gh-dark-mode-only +[very_good_workflows_link]: https://github.com/VeryGoodOpenSource/very_good_workflows diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..799268d --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1 @@ +include: package:very_good_analysis/analysis_options.5.1.0.yaml diff --git a/coverage_badge.svg b/coverage_badge.svg new file mode 100644 index 0000000..499e98c --- /dev/null +++ b/coverage_badge.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + coverage + coverage + 100% + 100% + + diff --git a/lib/instantly_sdk.dart b/lib/instantly_sdk.dart new file mode 100644 index 0000000..cd0f59c --- /dev/null +++ b/lib/instantly_sdk.dart @@ -0,0 +1,5 @@ +/// A Very Good Project created by Very Good CLI. +library instantly_sdk_dart; + +export 'src/instantly_api_client.dart'; +export 'src/models/instantly_models.dart'; diff --git a/lib/src/instantly_api_client.dart b/lib/src/instantly_api_client.dart new file mode 100644 index 0000000..ba2fad6 --- /dev/null +++ b/lib/src/instantly_api_client.dart @@ -0,0 +1,489 @@ +import 'package:dio/dio.dart'; +import 'package:instantly_sdk/instantly_sdk.dart'; + +/// A client that calls endpoints in the Instantly API. +class InstantlyApiClient { + /// Creates a new InstantlyApiClient to call the Instantly API. + /// + /// [apiKey] is the API key used to authenticate with the Instantly API. + /// You can find yours at https://app.instantly.ai/app/settings/integrations + InstantlyApiClient({ + required String apiKey, + }) : _apiKey = apiKey, + _dio = Dio( + BaseOptions( + baseUrl: '$_baseUrl$_apiVersion', + headers: { + 'Content-Type': 'application/json', + }, + queryParameters: { + 'api_key': apiKey, + }, + ), + ); + + static const _baseUrl = 'https://api.instantly.ai/api/'; + static const _apiVersion = 'v1'; + + final Dio _dio; + final String _apiKey; + + /// Lists all campaigns in the Instantly API. + Future> listCampaigns({String? skip, String? limit}) async { + final response = await _dio.get>( + '/campaign/list', + queryParameters: { + 'skip': skip, + 'limit': limit, + }, + ); + + if (response.data == null) { + // TODO(@a-wallen): throw a custom exception + return []; + } + + return response.data! + .map((e) => Campaign.fromJson(e as Map)) + .toList(); + } + + /// Creates a new campaign in the Instantly API. + Future getCampaignName({required String campaignId}) async { + final response = await _dio.get>( + '/campaign/get/name', + queryParameters: { + 'campaign_id': campaignId, + }, + ); + + if (response.data == null) { + // TODO(@a-wallen): throw a custom exception + return null; + } + + return Campaign.fromJson(response.data!); + } + + /// Gets the status of a campaign in the Instantly API. + Future getCampaignStatus({required String campaignId}) async { + final response = await _dio.get>( + '/campaign/get/status', + queryParameters: { + 'campaign_id': campaignId, + }, + ); + + if (response.data == null) { + // TODO(@a-wallen): throw a custom exception + return null; + } + + return Campaign.fromJson(response.data!); + } + + /// Sets the name of a campaign in the Instantly API. + Future setCampaignName({ + required String campaignId, + required String newName, + }) async { + await _dio.post('/campaign/set/name', data: { + 'campaign_id': campaignId, + 'name': newName, + }); + } + + /// Gets the accounts that are sending emails for a campaign in the + /// Instantly API. + Future getCampaignAccounts({ + required String campaignId, + }) async { + final response = await _dio.get>( + '/campaign/get/accounts', + queryParameters: { + 'campaign_id': campaignId, + }, + ); + + return Campaign( + id: campaignId, + accounts: response.data?.map((e) => Account(email: e)).toList(), + ); + } + + /// Sets the accounts that are sending emails for a campaign in the + /// Instantly API. + Future setCampaignAccounts({ + required String campaignId, + required List accounts, + }) async { + await _dio.post('/campaign/set/accounts', data: { + 'campaign_id': campaignId, + 'account_list': accounts, + }); + } + + /// Adds an account to the list of accounts sending emails for a campaign in + /// the Instantly API. + Future addSendingAccount({ + required String campaignId, + required String email, + }) async { + await _dio.post( + '/campaign/add/account', + data: { + 'campaign_id': campaignId, + 'email': email, + }, + ); + } + + /// Removes an account from the list of accounts sending emails for a campaign + /// in the Instantly API. + Future removeSendingAccount({ + required String campaignId, + required String email, + }) async { + await _dio.post( + '/campaign/remove/account', + data: { + 'campaign_id': campaignId, + 'email': email, + }, + ); + } + + /// Gets the schedules for a campaign in the Instantly API. + Future setCampaignSchedule({ + required String campaignId, + required Schedule schedule, + }) async { + await _dio.post('/campaign/set/schedules', data: { + 'campaign_id': campaignId, + 'schedules': [schedule.toJson()], // Assuming Schedule is a model class + }); + } + + /// Launches a campaign in the Instantly API. + Future launchCampaign({ + required String campaignId, + }) async { + await _dio.post('/campaign/launch', data: { + 'campaign_id': campaignId, + }); + } + + /// Pauses a campaign in the Instantly API. + Future pauseCampaign({ + required String campaignId, + }) async { + await _dio.post('/campaign/pause', data: { + 'campaign_id': campaignId, + }); + } + + /// Gets the summary of a campaign in the Instantly API. + Future getCampaignSummary({ + required String campaignId, + }) async { + final response = await _dio.get>( + '/analytics/campaign/summary', + queryParameters: { + 'campaign_id': campaignId, + }, + ); + + if (response.data == null) { + // TODO(@a-wallen): throw a custom exception + return null; + } + + return CampaignSummary.fromJson(response.data!); + } + + /// Gets the counts for a campaign in the Instantly API. + Future> getCampaignCounts({ + String? campaignId, + String? startDate, + String? endDate, + }) async { + final response = await _dio.get>( + '/analytics/campaign/count', + queryParameters: { + if (campaignId != null) 'campaign_id': campaignId, + 'start_date': startDate, + 'end_date': endDate, + }, + ); + + if (response.data == null) { + // TODO(@a-wallen): throw a custom exception + return []; + } + + return (response.data!) + .map((e) => CampaignCount.fromJson(e as Map)) + .toList(); + } + + /// Gets the leads for a campaign in the Instantly API. + Future addLeadsToCampaign({ + required String campaignId, + List leads = const [], + }) async { + await _dio.post( + '/lead/add', + data: { + 'api_key': _apiKey, + 'campaign_id': campaignId, + 'leads': leads.map((lead) => lead.toJson()).toList(), + }, + ); + } + + /// Gets the leads for a campaign in the Instantly API. + Future getOrSearchLead({ + required String email, + String? campaignId, + }) async { + final response = await _dio.get>( + '/lead/get', + queryParameters: { + 'api_key': _apiKey, + 'campaign_id': campaignId, + 'email': email, + }, + ); + + if (response.data == null) { + // TODO(@a-wallen): throw a custom exception + return null; + } + + return Lead.fromJson(response.data!); + } + + /// Gets the leads for a campaign in the Instantly API. + Future deleteLeadsFromCampaign({ + required String campaignId, + List emails = const [], + }) async { + await _dio.post( + '/lead/delete', + data: { + 'api_key': _apiKey, + 'campaign_id': campaignId, + 'delete_list': emails, + }, + ); + } + + /// Gets the leads for a campaign in the Instantly API. + Future updateLeadStatus({ + required String campaignId, + required String email, + required String newStatus, + }) async { + await _dio.post( + '/lead/update/status', + data: { + 'api_key': _apiKey, + 'campaign_id': campaignId, + 'email': email, + 'new_status': newStatus, + }, + ); + } + + /// Updates the variables for a lead in the Instantly API. + Future updateLeadVariables({ + required String campaignId, + required String email, + required Map variables, + }) async { + await _dio.post( + '/lead/data/update', + data: { + 'api_key': _apiKey, + 'campaign_id': campaignId, + 'email': email, + 'variables': variables, + }, + ); + } + + /// Adds an email or domain to the blocklist for a campaign in the Instantly + Future addToBlocklist({ + required String campaignId, + required String emailOrDomain, + }) async { + await _dio.post( + '/blocklist/add', + data: { + 'campaign_id': campaignId, + 'item': emailOrDomain, // Assuming the API expects a single item to add + }, + ); + } + + /// Removes an email or domain from the blocklist for a campaign in the + /// Instantly API. + Future removeFromBlocklist({ + required String campaignId, + required String emailOrDomain, + }) async { + await _dio.post( + '/blocklist/remove', + data: { + 'campaign_id': campaignId, + 'item': + emailOrDomain, // Assuming the API uses a similar payload structure for removal + }, + ); + } + + /// Lists all accounts in the Instantly API. + Future> listAccounts({ + int? limit, + int? skip, + }) async { + final response = await _dio.get>( + '/account/list', + queryParameters: { + 'limit': limit, + 'skip': skip, + }, + ); + + if (response.data == null) { + /// TODO(@a-wallen): throw a custom exception + return []; + } + + return response.data! + .map((e) => Account.fromJson(e as Map)) + .toList(); + } + + /// Gets the vitals for an account in the Instantly API. + Future checkAccountVitals({ + List accounts = const [], + }) async { + final response = await _dio.post>( + '/account/test/vitals', + data: { + 'accounts': accounts, + }, + ); + + // TODO(a-wallen): Handle errors + return AccountVitals.fromJson(response.data!); + } + + /// Gets the status of an account in the Instantly API. + Future getAccountStatus({ + required String email, + }) async { + final response = await _dio.get>( + '/account/status', + queryParameters: {'email': email}, + ); + + if (response.data == null) { + // TODO(@a-wallen): throw a custom exception + return null; + } + + return AccountStatus.fromJson(response.data!); + } + + /// Enables the warmup process for an account in the Instantly API. + Future enableWarmup({ + required String email, + }) async { + await _dio.post( + '/account/warmup/enable', + data: {'email': email}, + ); + } + + /// Disables the warmup status of an account in the Instantly API. + Future pauseWarmup({ + required String email, + }) async { + await _dio.post( + '/account/warmup/pause', + data: {'email': email}, + ); + } + + /// Marks an account as fixed in the Instantly API. + Future markAccountAsFixed({ + String? email, + }) async { + await _dio.post( + '/account/mark_fixed', + data: { + if (email != null) 'email': email, + }, + ); + } + + /// Deletes an account from the Instantly API. + Future deleteAccount({ + required String email, + }) async { + await _dio.post( + '/account/delete', + data: {'email': email}, + ); + } + + /// Lists all emails in the Instantly API. + Future> listEmails() async { + final response = await _dio.get>( + '/unibox/emails/', + queryParameters: { + 'api_key': _apiKey, + }, + ); + + if (response.data == null) { + // TODO(@a-wallen): throw a custom exception + return []; + } + + return response.data! + .map((e) => Email.fromJson(e as Map)) + .toList(); + } + + /// Counts the unread emails in the Instantly API. + Future countUnreadEmails() async { + final response = await _dio.get>( + '/unibox/emails/count/unread', + queryParameters: { + 'api_key': _apiKey, + }, + ); + + if (response.data == null) { + // TODO(@a-wallen): throw a custom exception + return null; + } + + return response.data?['count'] as int?; + } + + /// Marks an email as read in the Instantly API. + Future markThreadAsRead({ + required String threadId, + }) async { + await _dio.post( + '/unibox/threads/$threadId/mark-as-read', + data: { + 'api_key': _apiKey, + }, + ); + } +} diff --git a/lib/src/models/account.dart b/lib/src/models/account.dart new file mode 100644 index 0000000..0903276 --- /dev/null +++ b/lib/src/models/account.dart @@ -0,0 +1,28 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'account.freezed.dart'; +part 'account.g.dart'; + +/// An account that can be used to send emails. +@freezed +class Account with _$Account { + /// Default constructor for the account. + const factory Account({ + required String email, + @JsonKey(name: 'timestamp_created') DateTime? timestampCreated, + @JsonKey(name: 'timestamp_updated') DateTime? timestampUpdated, + String? status, + @JsonKey(name: 'warmup_status') String? warmupStatus, + @JsonKey(name: 'imap_host') String? imapHost, + @JsonKey(name: 'imap_port') int? imapPort, + @JsonKey(name: 'smtp_host') String? smtpHost, + @JsonKey(name: 'smtp_port') String? smtpPort, + @JsonKey(name: 'daily_limit') int? dailyLimit, + @JsonKey(name: 'sending_gap') String? sendingGap, + // Add additional fields as necessary + }) = _Account; + + /// Create an account from a JSON object. + factory Account.fromJson(Map json) => + _$AccountFromJson(json); +} diff --git a/lib/src/models/account.freezed.dart b/lib/src/models/account.freezed.dart new file mode 100644 index 0000000..abd3d12 --- /dev/null +++ b/lib/src/models/account.freezed.dart @@ -0,0 +1,399 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'account.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +Account _$AccountFromJson(Map json) { + return _Account.fromJson(json); +} + +/// @nodoc +mixin _$Account { + String get email => throw _privateConstructorUsedError; + @JsonKey(name: 'timestamp_created') + DateTime? get timestampCreated => throw _privateConstructorUsedError; + @JsonKey(name: 'timestamp_updated') + DateTime? get timestampUpdated => throw _privateConstructorUsedError; + String? get status => throw _privateConstructorUsedError; + @JsonKey(name: 'warmup_status') + String? get warmupStatus => throw _privateConstructorUsedError; + @JsonKey(name: 'imap_host') + String? get imapHost => throw _privateConstructorUsedError; + @JsonKey(name: 'imap_port') + int? get imapPort => throw _privateConstructorUsedError; + @JsonKey(name: 'smtp_host') + String? get smtpHost => throw _privateConstructorUsedError; + @JsonKey(name: 'smtp_port') + String? get smtpPort => throw _privateConstructorUsedError; + @JsonKey(name: 'daily_limit') + int? get dailyLimit => throw _privateConstructorUsedError; + @JsonKey(name: 'sending_gap') + String? get sendingGap => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $AccountCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $AccountCopyWith<$Res> { + factory $AccountCopyWith(Account value, $Res Function(Account) then) = + _$AccountCopyWithImpl<$Res, Account>; + @useResult + $Res call( + {String email, + @JsonKey(name: 'timestamp_created') DateTime? timestampCreated, + @JsonKey(name: 'timestamp_updated') DateTime? timestampUpdated, + String? status, + @JsonKey(name: 'warmup_status') String? warmupStatus, + @JsonKey(name: 'imap_host') String? imapHost, + @JsonKey(name: 'imap_port') int? imapPort, + @JsonKey(name: 'smtp_host') String? smtpHost, + @JsonKey(name: 'smtp_port') String? smtpPort, + @JsonKey(name: 'daily_limit') int? dailyLimit, + @JsonKey(name: 'sending_gap') String? sendingGap}); +} + +/// @nodoc +class _$AccountCopyWithImpl<$Res, $Val extends Account> + implements $AccountCopyWith<$Res> { + _$AccountCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? email = null, + Object? timestampCreated = freezed, + Object? timestampUpdated = freezed, + Object? status = freezed, + Object? warmupStatus = freezed, + Object? imapHost = freezed, + Object? imapPort = freezed, + Object? smtpHost = freezed, + Object? smtpPort = freezed, + Object? dailyLimit = freezed, + Object? sendingGap = freezed, + }) { + return _then(_value.copyWith( + email: null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + timestampCreated: freezed == timestampCreated + ? _value.timestampCreated + : timestampCreated // ignore: cast_nullable_to_non_nullable + as DateTime?, + timestampUpdated: freezed == timestampUpdated + ? _value.timestampUpdated + : timestampUpdated // ignore: cast_nullable_to_non_nullable + as DateTime?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + warmupStatus: freezed == warmupStatus + ? _value.warmupStatus + : warmupStatus // ignore: cast_nullable_to_non_nullable + as String?, + imapHost: freezed == imapHost + ? _value.imapHost + : imapHost // ignore: cast_nullable_to_non_nullable + as String?, + imapPort: freezed == imapPort + ? _value.imapPort + : imapPort // ignore: cast_nullable_to_non_nullable + as int?, + smtpHost: freezed == smtpHost + ? _value.smtpHost + : smtpHost // ignore: cast_nullable_to_non_nullable + as String?, + smtpPort: freezed == smtpPort + ? _value.smtpPort + : smtpPort // ignore: cast_nullable_to_non_nullable + as String?, + dailyLimit: freezed == dailyLimit + ? _value.dailyLimit + : dailyLimit // ignore: cast_nullable_to_non_nullable + as int?, + sendingGap: freezed == sendingGap + ? _value.sendingGap + : sendingGap // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$AccountImplCopyWith<$Res> implements $AccountCopyWith<$Res> { + factory _$$AccountImplCopyWith( + _$AccountImpl value, $Res Function(_$AccountImpl) then) = + __$$AccountImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String email, + @JsonKey(name: 'timestamp_created') DateTime? timestampCreated, + @JsonKey(name: 'timestamp_updated') DateTime? timestampUpdated, + String? status, + @JsonKey(name: 'warmup_status') String? warmupStatus, + @JsonKey(name: 'imap_host') String? imapHost, + @JsonKey(name: 'imap_port') int? imapPort, + @JsonKey(name: 'smtp_host') String? smtpHost, + @JsonKey(name: 'smtp_port') String? smtpPort, + @JsonKey(name: 'daily_limit') int? dailyLimit, + @JsonKey(name: 'sending_gap') String? sendingGap}); +} + +/// @nodoc +class __$$AccountImplCopyWithImpl<$Res> + extends _$AccountCopyWithImpl<$Res, _$AccountImpl> + implements _$$AccountImplCopyWith<$Res> { + __$$AccountImplCopyWithImpl( + _$AccountImpl _value, $Res Function(_$AccountImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? email = null, + Object? timestampCreated = freezed, + Object? timestampUpdated = freezed, + Object? status = freezed, + Object? warmupStatus = freezed, + Object? imapHost = freezed, + Object? imapPort = freezed, + Object? smtpHost = freezed, + Object? smtpPort = freezed, + Object? dailyLimit = freezed, + Object? sendingGap = freezed, + }) { + return _then(_$AccountImpl( + email: null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + timestampCreated: freezed == timestampCreated + ? _value.timestampCreated + : timestampCreated // ignore: cast_nullable_to_non_nullable + as DateTime?, + timestampUpdated: freezed == timestampUpdated + ? _value.timestampUpdated + : timestampUpdated // ignore: cast_nullable_to_non_nullable + as DateTime?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + warmupStatus: freezed == warmupStatus + ? _value.warmupStatus + : warmupStatus // ignore: cast_nullable_to_non_nullable + as String?, + imapHost: freezed == imapHost + ? _value.imapHost + : imapHost // ignore: cast_nullable_to_non_nullable + as String?, + imapPort: freezed == imapPort + ? _value.imapPort + : imapPort // ignore: cast_nullable_to_non_nullable + as int?, + smtpHost: freezed == smtpHost + ? _value.smtpHost + : smtpHost // ignore: cast_nullable_to_non_nullable + as String?, + smtpPort: freezed == smtpPort + ? _value.smtpPort + : smtpPort // ignore: cast_nullable_to_non_nullable + as String?, + dailyLimit: freezed == dailyLimit + ? _value.dailyLimit + : dailyLimit // ignore: cast_nullable_to_non_nullable + as int?, + sendingGap: freezed == sendingGap + ? _value.sendingGap + : sendingGap // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$AccountImpl implements _Account { + const _$AccountImpl( + {required this.email, + @JsonKey(name: 'timestamp_created') this.timestampCreated, + @JsonKey(name: 'timestamp_updated') this.timestampUpdated, + this.status, + @JsonKey(name: 'warmup_status') this.warmupStatus, + @JsonKey(name: 'imap_host') this.imapHost, + @JsonKey(name: 'imap_port') this.imapPort, + @JsonKey(name: 'smtp_host') this.smtpHost, + @JsonKey(name: 'smtp_port') this.smtpPort, + @JsonKey(name: 'daily_limit') this.dailyLimit, + @JsonKey(name: 'sending_gap') this.sendingGap}); + + factory _$AccountImpl.fromJson(Map json) => + _$$AccountImplFromJson(json); + + @override + final String email; + @override + @JsonKey(name: 'timestamp_created') + final DateTime? timestampCreated; + @override + @JsonKey(name: 'timestamp_updated') + final DateTime? timestampUpdated; + @override + final String? status; + @override + @JsonKey(name: 'warmup_status') + final String? warmupStatus; + @override + @JsonKey(name: 'imap_host') + final String? imapHost; + @override + @JsonKey(name: 'imap_port') + final int? imapPort; + @override + @JsonKey(name: 'smtp_host') + final String? smtpHost; + @override + @JsonKey(name: 'smtp_port') + final String? smtpPort; + @override + @JsonKey(name: 'daily_limit') + final int? dailyLimit; + @override + @JsonKey(name: 'sending_gap') + final String? sendingGap; + + @override + String toString() { + return 'Account(email: $email, timestampCreated: $timestampCreated, timestampUpdated: $timestampUpdated, status: $status, warmupStatus: $warmupStatus, imapHost: $imapHost, imapPort: $imapPort, smtpHost: $smtpHost, smtpPort: $smtpPort, dailyLimit: $dailyLimit, sendingGap: $sendingGap)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AccountImpl && + (identical(other.email, email) || other.email == email) && + (identical(other.timestampCreated, timestampCreated) || + other.timestampCreated == timestampCreated) && + (identical(other.timestampUpdated, timestampUpdated) || + other.timestampUpdated == timestampUpdated) && + (identical(other.status, status) || other.status == status) && + (identical(other.warmupStatus, warmupStatus) || + other.warmupStatus == warmupStatus) && + (identical(other.imapHost, imapHost) || + other.imapHost == imapHost) && + (identical(other.imapPort, imapPort) || + other.imapPort == imapPort) && + (identical(other.smtpHost, smtpHost) || + other.smtpHost == smtpHost) && + (identical(other.smtpPort, smtpPort) || + other.smtpPort == smtpPort) && + (identical(other.dailyLimit, dailyLimit) || + other.dailyLimit == dailyLimit) && + (identical(other.sendingGap, sendingGap) || + other.sendingGap == sendingGap)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + email, + timestampCreated, + timestampUpdated, + status, + warmupStatus, + imapHost, + imapPort, + smtpHost, + smtpPort, + dailyLimit, + sendingGap); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AccountImplCopyWith<_$AccountImpl> get copyWith => + __$$AccountImplCopyWithImpl<_$AccountImpl>(this, _$identity); + + @override + Map toJson() { + return _$$AccountImplToJson( + this, + ); + } +} + +abstract class _Account implements Account { + const factory _Account( + {required final String email, + @JsonKey(name: 'timestamp_created') final DateTime? timestampCreated, + @JsonKey(name: 'timestamp_updated') final DateTime? timestampUpdated, + final String? status, + @JsonKey(name: 'warmup_status') final String? warmupStatus, + @JsonKey(name: 'imap_host') final String? imapHost, + @JsonKey(name: 'imap_port') final int? imapPort, + @JsonKey(name: 'smtp_host') final String? smtpHost, + @JsonKey(name: 'smtp_port') final String? smtpPort, + @JsonKey(name: 'daily_limit') final int? dailyLimit, + @JsonKey(name: 'sending_gap') final String? sendingGap}) = _$AccountImpl; + + factory _Account.fromJson(Map json) = _$AccountImpl.fromJson; + + @override + String get email; + @override + @JsonKey(name: 'timestamp_created') + DateTime? get timestampCreated; + @override + @JsonKey(name: 'timestamp_updated') + DateTime? get timestampUpdated; + @override + String? get status; + @override + @JsonKey(name: 'warmup_status') + String? get warmupStatus; + @override + @JsonKey(name: 'imap_host') + String? get imapHost; + @override + @JsonKey(name: 'imap_port') + int? get imapPort; + @override + @JsonKey(name: 'smtp_host') + String? get smtpHost; + @override + @JsonKey(name: 'smtp_port') + String? get smtpPort; + @override + @JsonKey(name: 'daily_limit') + int? get dailyLimit; + @override + @JsonKey(name: 'sending_gap') + String? get sendingGap; + @override + @JsonKey(ignore: true) + _$$AccountImplCopyWith<_$AccountImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/models/account.g.dart b/lib/src/models/account.g.dart new file mode 100644 index 0000000..d52e2de --- /dev/null +++ b/lib/src/models/account.g.dart @@ -0,0 +1,41 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'account.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$AccountImpl _$$AccountImplFromJson(Map json) => + _$AccountImpl( + email: json['email'] as String, + timestampCreated: json['timestamp_created'] == null + ? null + : DateTime.parse(json['timestamp_created'] as String), + timestampUpdated: json['timestamp_updated'] == null + ? null + : DateTime.parse(json['timestamp_updated'] as String), + status: json['status'] as String?, + warmupStatus: json['warmup_status'] as String?, + imapHost: json['imap_host'] as String?, + imapPort: json['imap_port'] as int?, + smtpHost: json['smtp_host'] as String?, + smtpPort: json['smtp_port'] as String?, + dailyLimit: json['daily_limit'] as int?, + sendingGap: json['sending_gap'] as String?, + ); + +Map _$$AccountImplToJson(_$AccountImpl instance) => + { + 'email': instance.email, + 'timestamp_created': instance.timestampCreated?.toIso8601String(), + 'timestamp_updated': instance.timestampUpdated?.toIso8601String(), + 'status': instance.status, + 'warmup_status': instance.warmupStatus, + 'imap_host': instance.imapHost, + 'imap_port': instance.imapPort, + 'smtp_host': instance.smtpHost, + 'smtp_port': instance.smtpPort, + 'daily_limit': instance.dailyLimit, + 'sending_gap': instance.sendingGap, + }; diff --git a/lib/src/models/account_status.dart b/lib/src/models/account_status.dart new file mode 100644 index 0000000..11c4735 --- /dev/null +++ b/lib/src/models/account_status.dart @@ -0,0 +1,16 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'account_status.freezed.dart'; +part 'account_status.g.dart'; + +@freezed +class AccountStatus with _$AccountStatus { + const factory AccountStatus({ + required String account, + required String status, + @JsonKey(name: 'warmup_status') required String warmupStatus, + }) = _AccountStatus; + + factory AccountStatus.fromJson(Map json) => + _$AccountStatusFromJson(json); +} diff --git a/lib/src/models/account_status.freezed.dart b/lib/src/models/account_status.freezed.dart new file mode 100644 index 0000000..0f7e6bc --- /dev/null +++ b/lib/src/models/account_status.freezed.dart @@ -0,0 +1,200 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'account_status.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +AccountStatus _$AccountStatusFromJson(Map json) { + return _AccountStatus.fromJson(json); +} + +/// @nodoc +mixin _$AccountStatus { + String get account => throw _privateConstructorUsedError; + String get status => throw _privateConstructorUsedError; + @JsonKey(name: 'warmup_status') + String get warmupStatus => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $AccountStatusCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $AccountStatusCopyWith<$Res> { + factory $AccountStatusCopyWith( + AccountStatus value, $Res Function(AccountStatus) then) = + _$AccountStatusCopyWithImpl<$Res, AccountStatus>; + @useResult + $Res call( + {String account, + String status, + @JsonKey(name: 'warmup_status') String warmupStatus}); +} + +/// @nodoc +class _$AccountStatusCopyWithImpl<$Res, $Val extends AccountStatus> + implements $AccountStatusCopyWith<$Res> { + _$AccountStatusCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? account = null, + Object? status = null, + Object? warmupStatus = null, + }) { + return _then(_value.copyWith( + account: null == account + ? _value.account + : account // ignore: cast_nullable_to_non_nullable + as String, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + warmupStatus: null == warmupStatus + ? _value.warmupStatus + : warmupStatus // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$AccountStatusImplCopyWith<$Res> + implements $AccountStatusCopyWith<$Res> { + factory _$$AccountStatusImplCopyWith( + _$AccountStatusImpl value, $Res Function(_$AccountStatusImpl) then) = + __$$AccountStatusImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String account, + String status, + @JsonKey(name: 'warmup_status') String warmupStatus}); +} + +/// @nodoc +class __$$AccountStatusImplCopyWithImpl<$Res> + extends _$AccountStatusCopyWithImpl<$Res, _$AccountStatusImpl> + implements _$$AccountStatusImplCopyWith<$Res> { + __$$AccountStatusImplCopyWithImpl( + _$AccountStatusImpl _value, $Res Function(_$AccountStatusImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? account = null, + Object? status = null, + Object? warmupStatus = null, + }) { + return _then(_$AccountStatusImpl( + account: null == account + ? _value.account + : account // ignore: cast_nullable_to_non_nullable + as String, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + warmupStatus: null == warmupStatus + ? _value.warmupStatus + : warmupStatus // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$AccountStatusImpl implements _AccountStatus { + const _$AccountStatusImpl( + {required this.account, + required this.status, + @JsonKey(name: 'warmup_status') required this.warmupStatus}); + + factory _$AccountStatusImpl.fromJson(Map json) => + _$$AccountStatusImplFromJson(json); + + @override + final String account; + @override + final String status; + @override + @JsonKey(name: 'warmup_status') + final String warmupStatus; + + @override + String toString() { + return 'AccountStatus(account: $account, status: $status, warmupStatus: $warmupStatus)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AccountStatusImpl && + (identical(other.account, account) || other.account == account) && + (identical(other.status, status) || other.status == status) && + (identical(other.warmupStatus, warmupStatus) || + other.warmupStatus == warmupStatus)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, account, status, warmupStatus); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AccountStatusImplCopyWith<_$AccountStatusImpl> get copyWith => + __$$AccountStatusImplCopyWithImpl<_$AccountStatusImpl>(this, _$identity); + + @override + Map toJson() { + return _$$AccountStatusImplToJson( + this, + ); + } +} + +abstract class _AccountStatus implements AccountStatus { + const factory _AccountStatus( + {required final String account, + required final String status, + @JsonKey(name: 'warmup_status') required final String warmupStatus}) = + _$AccountStatusImpl; + + factory _AccountStatus.fromJson(Map json) = + _$AccountStatusImpl.fromJson; + + @override + String get account; + @override + String get status; + @override + @JsonKey(name: 'warmup_status') + String get warmupStatus; + @override + @JsonKey(ignore: true) + _$$AccountStatusImplCopyWith<_$AccountStatusImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/models/account_status.g.dart b/lib/src/models/account_status.g.dart new file mode 100644 index 0000000..dba6bb6 --- /dev/null +++ b/lib/src/models/account_status.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'account_status.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$AccountStatusImpl _$$AccountStatusImplFromJson(Map json) => + _$AccountStatusImpl( + account: json['account'] as String, + status: json['status'] as String, + warmupStatus: json['warmup_status'] as String, + ); + +Map _$$AccountStatusImplToJson(_$AccountStatusImpl instance) => + { + 'account': instance.account, + 'status': instance.status, + 'warmup_status': instance.warmupStatus, + }; diff --git a/lib/src/models/account_vitals.dart b/lib/src/models/account_vitals.dart new file mode 100644 index 0000000..e78b26a --- /dev/null +++ b/lib/src/models/account_vitals.dart @@ -0,0 +1,38 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'account_vitals.freezed.dart'; +part 'account_vitals.g.dart'; + +/// The vitals of an account. +@freezed +class AccountVitals with _$AccountVitals { + /// Default constructor for the account vitals. + const factory AccountVitals({ + required String status, + required List successList, + required List failureList, + }) = _AccountVitals; + + /// Create account vitals from a JSON object. + factory AccountVitals.fromJson(Map json) => + _$AccountVitalsFromJson(json); +} + +/// The vitals of an account. +@freezed +class VitalStatus with _$VitalStatus { + /// Default constructor for the vital status. + const factory VitalStatus({ + required String domain, + @JsonKey(name: 'allPass') required bool allPass, + required bool mx, + required bool spf, + required dynamic + dkim, // Use dynamic to accommodate both boolean and string values + required bool dmarc, + }) = _VitalStatus; + + /// Create vital status from a JSON object. + factory VitalStatus.fromJson(Map json) => + _$VitalStatusFromJson(json); +} diff --git a/lib/src/models/account_vitals.freezed.dart b/lib/src/models/account_vitals.freezed.dart new file mode 100644 index 0000000..4fff2a8 --- /dev/null +++ b/lib/src/models/account_vitals.freezed.dart @@ -0,0 +1,460 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'account_vitals.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +AccountVitals _$AccountVitalsFromJson(Map json) { + return _AccountVitals.fromJson(json); +} + +/// @nodoc +mixin _$AccountVitals { + String get status => throw _privateConstructorUsedError; + List get successList => throw _privateConstructorUsedError; + List get failureList => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $AccountVitalsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $AccountVitalsCopyWith<$Res> { + factory $AccountVitalsCopyWith( + AccountVitals value, $Res Function(AccountVitals) then) = + _$AccountVitalsCopyWithImpl<$Res, AccountVitals>; + @useResult + $Res call( + {String status, + List successList, + List failureList}); +} + +/// @nodoc +class _$AccountVitalsCopyWithImpl<$Res, $Val extends AccountVitals> + implements $AccountVitalsCopyWith<$Res> { + _$AccountVitalsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? status = null, + Object? successList = null, + Object? failureList = null, + }) { + return _then(_value.copyWith( + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + successList: null == successList + ? _value.successList + : successList // ignore: cast_nullable_to_non_nullable + as List, + failureList: null == failureList + ? _value.failureList + : failureList // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$AccountVitalsImplCopyWith<$Res> + implements $AccountVitalsCopyWith<$Res> { + factory _$$AccountVitalsImplCopyWith( + _$AccountVitalsImpl value, $Res Function(_$AccountVitalsImpl) then) = + __$$AccountVitalsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String status, + List successList, + List failureList}); +} + +/// @nodoc +class __$$AccountVitalsImplCopyWithImpl<$Res> + extends _$AccountVitalsCopyWithImpl<$Res, _$AccountVitalsImpl> + implements _$$AccountVitalsImplCopyWith<$Res> { + __$$AccountVitalsImplCopyWithImpl( + _$AccountVitalsImpl _value, $Res Function(_$AccountVitalsImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? status = null, + Object? successList = null, + Object? failureList = null, + }) { + return _then(_$AccountVitalsImpl( + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + successList: null == successList + ? _value._successList + : successList // ignore: cast_nullable_to_non_nullable + as List, + failureList: null == failureList + ? _value._failureList + : failureList // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$AccountVitalsImpl implements _AccountVitals { + const _$AccountVitalsImpl( + {required this.status, + required final List successList, + required final List failureList}) + : _successList = successList, + _failureList = failureList; + + factory _$AccountVitalsImpl.fromJson(Map json) => + _$$AccountVitalsImplFromJson(json); + + @override + final String status; + final List _successList; + @override + List get successList { + if (_successList is EqualUnmodifiableListView) return _successList; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_successList); + } + + final List _failureList; + @override + List get failureList { + if (_failureList is EqualUnmodifiableListView) return _failureList; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_failureList); + } + + @override + String toString() { + return 'AccountVitals(status: $status, successList: $successList, failureList: $failureList)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AccountVitalsImpl && + (identical(other.status, status) || other.status == status) && + const DeepCollectionEquality() + .equals(other._successList, _successList) && + const DeepCollectionEquality() + .equals(other._failureList, _failureList)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + status, + const DeepCollectionEquality().hash(_successList), + const DeepCollectionEquality().hash(_failureList)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AccountVitalsImplCopyWith<_$AccountVitalsImpl> get copyWith => + __$$AccountVitalsImplCopyWithImpl<_$AccountVitalsImpl>(this, _$identity); + + @override + Map toJson() { + return _$$AccountVitalsImplToJson( + this, + ); + } +} + +abstract class _AccountVitals implements AccountVitals { + const factory _AccountVitals( + {required final String status, + required final List successList, + required final List failureList}) = _$AccountVitalsImpl; + + factory _AccountVitals.fromJson(Map json) = + _$AccountVitalsImpl.fromJson; + + @override + String get status; + @override + List get successList; + @override + List get failureList; + @override + @JsonKey(ignore: true) + _$$AccountVitalsImplCopyWith<_$AccountVitalsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +VitalStatus _$VitalStatusFromJson(Map json) { + return _VitalStatus.fromJson(json); +} + +/// @nodoc +mixin _$VitalStatus { + String get domain => throw _privateConstructorUsedError; + @JsonKey(name: 'allPass') + bool get allPass => throw _privateConstructorUsedError; + bool get mx => throw _privateConstructorUsedError; + bool get spf => throw _privateConstructorUsedError; + dynamic get dkim => + throw _privateConstructorUsedError; // Use dynamic to accommodate both boolean and string values + bool get dmarc => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $VitalStatusCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $VitalStatusCopyWith<$Res> { + factory $VitalStatusCopyWith( + VitalStatus value, $Res Function(VitalStatus) then) = + _$VitalStatusCopyWithImpl<$Res, VitalStatus>; + @useResult + $Res call( + {String domain, + @JsonKey(name: 'allPass') bool allPass, + bool mx, + bool spf, + dynamic dkim, + bool dmarc}); +} + +/// @nodoc +class _$VitalStatusCopyWithImpl<$Res, $Val extends VitalStatus> + implements $VitalStatusCopyWith<$Res> { + _$VitalStatusCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domain = null, + Object? allPass = null, + Object? mx = null, + Object? spf = null, + Object? dkim = freezed, + Object? dmarc = null, + }) { + return _then(_value.copyWith( + domain: null == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String, + allPass: null == allPass + ? _value.allPass + : allPass // ignore: cast_nullable_to_non_nullable + as bool, + mx: null == mx + ? _value.mx + : mx // ignore: cast_nullable_to_non_nullable + as bool, + spf: null == spf + ? _value.spf + : spf // ignore: cast_nullable_to_non_nullable + as bool, + dkim: freezed == dkim + ? _value.dkim + : dkim // ignore: cast_nullable_to_non_nullable + as dynamic, + dmarc: null == dmarc + ? _value.dmarc + : dmarc // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$VitalStatusImplCopyWith<$Res> + implements $VitalStatusCopyWith<$Res> { + factory _$$VitalStatusImplCopyWith( + _$VitalStatusImpl value, $Res Function(_$VitalStatusImpl) then) = + __$$VitalStatusImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String domain, + @JsonKey(name: 'allPass') bool allPass, + bool mx, + bool spf, + dynamic dkim, + bool dmarc}); +} + +/// @nodoc +class __$$VitalStatusImplCopyWithImpl<$Res> + extends _$VitalStatusCopyWithImpl<$Res, _$VitalStatusImpl> + implements _$$VitalStatusImplCopyWith<$Res> { + __$$VitalStatusImplCopyWithImpl( + _$VitalStatusImpl _value, $Res Function(_$VitalStatusImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domain = null, + Object? allPass = null, + Object? mx = null, + Object? spf = null, + Object? dkim = freezed, + Object? dmarc = null, + }) { + return _then(_$VitalStatusImpl( + domain: null == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String, + allPass: null == allPass + ? _value.allPass + : allPass // ignore: cast_nullable_to_non_nullable + as bool, + mx: null == mx + ? _value.mx + : mx // ignore: cast_nullable_to_non_nullable + as bool, + spf: null == spf + ? _value.spf + : spf // ignore: cast_nullable_to_non_nullable + as bool, + dkim: freezed == dkim + ? _value.dkim + : dkim // ignore: cast_nullable_to_non_nullable + as dynamic, + dmarc: null == dmarc + ? _value.dmarc + : dmarc // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$VitalStatusImpl implements _VitalStatus { + const _$VitalStatusImpl( + {required this.domain, + @JsonKey(name: 'allPass') required this.allPass, + required this.mx, + required this.spf, + required this.dkim, + required this.dmarc}); + + factory _$VitalStatusImpl.fromJson(Map json) => + _$$VitalStatusImplFromJson(json); + + @override + final String domain; + @override + @JsonKey(name: 'allPass') + final bool allPass; + @override + final bool mx; + @override + final bool spf; + @override + final dynamic dkim; +// Use dynamic to accommodate both boolean and string values + @override + final bool dmarc; + + @override + String toString() { + return 'VitalStatus(domain: $domain, allPass: $allPass, mx: $mx, spf: $spf, dkim: $dkim, dmarc: $dmarc)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$VitalStatusImpl && + (identical(other.domain, domain) || other.domain == domain) && + (identical(other.allPass, allPass) || other.allPass == allPass) && + (identical(other.mx, mx) || other.mx == mx) && + (identical(other.spf, spf) || other.spf == spf) && + const DeepCollectionEquality().equals(other.dkim, dkim) && + (identical(other.dmarc, dmarc) || other.dmarc == dmarc)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, domain, allPass, mx, spf, + const DeepCollectionEquality().hash(dkim), dmarc); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$VitalStatusImplCopyWith<_$VitalStatusImpl> get copyWith => + __$$VitalStatusImplCopyWithImpl<_$VitalStatusImpl>(this, _$identity); + + @override + Map toJson() { + return _$$VitalStatusImplToJson( + this, + ); + } +} + +abstract class _VitalStatus implements VitalStatus { + const factory _VitalStatus( + {required final String domain, + @JsonKey(name: 'allPass') required final bool allPass, + required final bool mx, + required final bool spf, + required final dynamic dkim, + required final bool dmarc}) = _$VitalStatusImpl; + + factory _VitalStatus.fromJson(Map json) = + _$VitalStatusImpl.fromJson; + + @override + String get domain; + @override + @JsonKey(name: 'allPass') + bool get allPass; + @override + bool get mx; + @override + bool get spf; + @override + dynamic get dkim; + @override // Use dynamic to accommodate both boolean and string values + bool get dmarc; + @override + @JsonKey(ignore: true) + _$$VitalStatusImplCopyWith<_$VitalStatusImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/models/account_vitals.g.dart b/lib/src/models/account_vitals.g.dart new file mode 100644 index 0000000..f186652 --- /dev/null +++ b/lib/src/models/account_vitals.g.dart @@ -0,0 +1,45 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'account_vitals.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$AccountVitalsImpl _$$AccountVitalsImplFromJson(Map json) => + _$AccountVitalsImpl( + status: json['status'] as String, + successList: (json['successList'] as List) + .map((e) => VitalStatus.fromJson(e as Map)) + .toList(), + failureList: (json['failureList'] as List) + .map((e) => VitalStatus.fromJson(e as Map)) + .toList(), + ); + +Map _$$AccountVitalsImplToJson(_$AccountVitalsImpl instance) => + { + 'status': instance.status, + 'successList': instance.successList, + 'failureList': instance.failureList, + }; + +_$VitalStatusImpl _$$VitalStatusImplFromJson(Map json) => + _$VitalStatusImpl( + domain: json['domain'] as String, + allPass: json['allPass'] as bool, + mx: json['mx'] as bool, + spf: json['spf'] as bool, + dkim: json['dkim'], + dmarc: json['dmarc'] as bool, + ); + +Map _$$VitalStatusImplToJson(_$VitalStatusImpl instance) => + { + 'domain': instance.domain, + 'allPass': instance.allPass, + 'mx': instance.mx, + 'spf': instance.spf, + 'dkim': instance.dkim, + 'dmarc': instance.dmarc, + }; diff --git a/lib/src/models/campaign.dart b/lib/src/models/campaign.dart new file mode 100644 index 0000000..e42b376 --- /dev/null +++ b/lib/src/models/campaign.dart @@ -0,0 +1,61 @@ +// campaign.dart +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:instantly_sdk/instantly_sdk.dart'; + +part 'campaign.freezed.dart'; +part 'campaign.g.dart'; + +/// A campaign in the Instantly API. +@freezed +class Campaign with _$Campaign { + /// Default constructor for the campaign. + const factory Campaign({ + required String id, + String? name, + String? status, + List? accounts, + }) = _Campaign; + + /// Create a campaign from a JSON object. + factory Campaign.fromJson(Map json) => + _$CampaignFromJson(json); +} + +/// An extension for the campaign model. +extension CampaignExtension on Campaign { + /// Since Instantly has a weird design, use this function if + /// you got the campaign's status or accounts first and then + /// want to get the name. + Future getName(InstantlyApiClient client) async { + // If the name is already set, return a copy of the campaign. + if (name != null) return copyWith(); + + // If the name is not set, get the campaign from the API. + final campaign = await client.getCampaignName(campaignId: id); + return copyWith(name: campaign?.name); + } + + /// Since Instantly has a weird design, use this function if + /// you got the campaign's name or accounts first and then + /// want to get the status. + Future getStatus(InstantlyApiClient client) async { + // If the status is already set, return a copy of the campaign. + if (status != null) return copyWith(); + + // If the status is not set, get the campaign from the API. + final campaign = await client.getCampaignStatus(campaignId: id); + return copyWith(status: campaign?.status); + } + + /// Since Instantly has a weird design, use this function if + /// you got the campaign's name or status first and then + /// want to get the accounts. + Future getAccounts(InstantlyApiClient client) async { + // If the accounts are already set, return a copy of the campaign. + if (accounts != null) return copyWith(); + + // If the accounts are not set, get the campaign from the API. + final campaign = await client.getCampaignAccounts(campaignId: id); + return copyWith(accounts: campaign.accounts); + } +} diff --git a/lib/src/models/campaign.freezed.dart b/lib/src/models/campaign.freezed.dart new file mode 100644 index 0000000..97c5abf --- /dev/null +++ b/lib/src/models/campaign.freezed.dart @@ -0,0 +1,212 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'campaign.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +Campaign _$CampaignFromJson(Map json) { + return _Campaign.fromJson(json); +} + +/// @nodoc +mixin _$Campaign { + String get id => throw _privateConstructorUsedError; + String? get name => throw _privateConstructorUsedError; + String? get status => throw _privateConstructorUsedError; + List? get accounts => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $CampaignCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CampaignCopyWith<$Res> { + factory $CampaignCopyWith(Campaign value, $Res Function(Campaign) then) = + _$CampaignCopyWithImpl<$Res, Campaign>; + @useResult + $Res call({String id, String? name, String? status, List? accounts}); +} + +/// @nodoc +class _$CampaignCopyWithImpl<$Res, $Val extends Campaign> + implements $CampaignCopyWith<$Res> { + _$CampaignCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? name = freezed, + Object? status = freezed, + Object? accounts = freezed, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + accounts: freezed == accounts + ? _value.accounts + : accounts // ignore: cast_nullable_to_non_nullable + as List?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$CampaignImplCopyWith<$Res> + implements $CampaignCopyWith<$Res> { + factory _$$CampaignImplCopyWith( + _$CampaignImpl value, $Res Function(_$CampaignImpl) then) = + __$$CampaignImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String id, String? name, String? status, List? accounts}); +} + +/// @nodoc +class __$$CampaignImplCopyWithImpl<$Res> + extends _$CampaignCopyWithImpl<$Res, _$CampaignImpl> + implements _$$CampaignImplCopyWith<$Res> { + __$$CampaignImplCopyWithImpl( + _$CampaignImpl _value, $Res Function(_$CampaignImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? name = freezed, + Object? status = freezed, + Object? accounts = freezed, + }) { + return _then(_$CampaignImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + accounts: freezed == accounts + ? _value._accounts + : accounts // ignore: cast_nullable_to_non_nullable + as List?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$CampaignImpl implements _Campaign { + const _$CampaignImpl( + {required this.id, this.name, this.status, final List? accounts}) + : _accounts = accounts; + + factory _$CampaignImpl.fromJson(Map json) => + _$$CampaignImplFromJson(json); + + @override + final String id; + @override + final String? name; + @override + final String? status; + final List? _accounts; + @override + List? get accounts { + final value = _accounts; + if (value == null) return null; + if (_accounts is EqualUnmodifiableListView) return _accounts; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + String toString() { + return 'Campaign(id: $id, name: $name, status: $status, accounts: $accounts)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CampaignImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.name, name) || other.name == name) && + (identical(other.status, status) || other.status == status) && + const DeepCollectionEquality().equals(other._accounts, _accounts)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, id, name, status, + const DeepCollectionEquality().hash(_accounts)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$CampaignImplCopyWith<_$CampaignImpl> get copyWith => + __$$CampaignImplCopyWithImpl<_$CampaignImpl>(this, _$identity); + + @override + Map toJson() { + return _$$CampaignImplToJson( + this, + ); + } +} + +abstract class _Campaign implements Campaign { + const factory _Campaign( + {required final String id, + final String? name, + final String? status, + final List? accounts}) = _$CampaignImpl; + + factory _Campaign.fromJson(Map json) = + _$CampaignImpl.fromJson; + + @override + String get id; + @override + String? get name; + @override + String? get status; + @override + List? get accounts; + @override + @JsonKey(ignore: true) + _$$CampaignImplCopyWith<_$CampaignImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/models/campaign.g.dart b/lib/src/models/campaign.g.dart new file mode 100644 index 0000000..b623bcf --- /dev/null +++ b/lib/src/models/campaign.g.dart @@ -0,0 +1,25 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'campaign.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$CampaignImpl _$$CampaignImplFromJson(Map json) => + _$CampaignImpl( + id: json['id'] as String, + name: json['name'] as String?, + status: json['status'] as String?, + accounts: (json['accounts'] as List?) + ?.map((e) => Account.fromJson(e as Map)) + .toList(), + ); + +Map _$$CampaignImplToJson(_$CampaignImpl instance) => + { + 'id': instance.id, + 'name': instance.name, + 'status': instance.status, + 'accounts': instance.accounts, + }; diff --git a/lib/src/models/campaign_count.dart b/lib/src/models/campaign_count.dart new file mode 100644 index 0000000..0e4dde6 --- /dev/null +++ b/lib/src/models/campaign_count.dart @@ -0,0 +1,20 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'campaign_count.freezed.dart'; +part 'campaign_count.g.dart'; + +@freezed +class CampaignCount with _$CampaignCount { + const factory CampaignCount({ + @JsonKey(name: 'campaign_id') required String campaignId, + @JsonKey(name: 'campaign_name') String? campaignName, + @JsonKey(name: 'total_emails_sent') int? totalEmailsSent, + @JsonKey(name: 'emails_read') int? emailsRead, + @JsonKey(name: 'new_leads_contacted') int? newLeadsContacted, + @JsonKey(name: 'leads_replied') int? leadsReplied, + @JsonKey(name: 'leads_read') int? leadsRead, + }) = _CampaignCount; + + factory CampaignCount.fromJson(Map json) => + _$CampaignCountFromJson(json); +} diff --git a/lib/src/models/campaign_count.freezed.dart b/lib/src/models/campaign_count.freezed.dart new file mode 100644 index 0000000..a1c279b --- /dev/null +++ b/lib/src/models/campaign_count.freezed.dart @@ -0,0 +1,304 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'campaign_count.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +CampaignCount _$CampaignCountFromJson(Map json) { + return _CampaignCount.fromJson(json); +} + +/// @nodoc +mixin _$CampaignCount { + @JsonKey(name: 'campaign_id') + String get campaignId => throw _privateConstructorUsedError; + @JsonKey(name: 'campaign_name') + String? get campaignName => throw _privateConstructorUsedError; + @JsonKey(name: 'total_emails_sent') + int? get totalEmailsSent => throw _privateConstructorUsedError; + @JsonKey(name: 'emails_read') + int? get emailsRead => throw _privateConstructorUsedError; + @JsonKey(name: 'new_leads_contacted') + int? get newLeadsContacted => throw _privateConstructorUsedError; + @JsonKey(name: 'leads_replied') + int? get leadsReplied => throw _privateConstructorUsedError; + @JsonKey(name: 'leads_read') + int? get leadsRead => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $CampaignCountCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CampaignCountCopyWith<$Res> { + factory $CampaignCountCopyWith( + CampaignCount value, $Res Function(CampaignCount) then) = + _$CampaignCountCopyWithImpl<$Res, CampaignCount>; + @useResult + $Res call( + {@JsonKey(name: 'campaign_id') String campaignId, + @JsonKey(name: 'campaign_name') String? campaignName, + @JsonKey(name: 'total_emails_sent') int? totalEmailsSent, + @JsonKey(name: 'emails_read') int? emailsRead, + @JsonKey(name: 'new_leads_contacted') int? newLeadsContacted, + @JsonKey(name: 'leads_replied') int? leadsReplied, + @JsonKey(name: 'leads_read') int? leadsRead}); +} + +/// @nodoc +class _$CampaignCountCopyWithImpl<$Res, $Val extends CampaignCount> + implements $CampaignCountCopyWith<$Res> { + _$CampaignCountCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? campaignId = null, + Object? campaignName = freezed, + Object? totalEmailsSent = freezed, + Object? emailsRead = freezed, + Object? newLeadsContacted = freezed, + Object? leadsReplied = freezed, + Object? leadsRead = freezed, + }) { + return _then(_value.copyWith( + campaignId: null == campaignId + ? _value.campaignId + : campaignId // ignore: cast_nullable_to_non_nullable + as String, + campaignName: freezed == campaignName + ? _value.campaignName + : campaignName // ignore: cast_nullable_to_non_nullable + as String?, + totalEmailsSent: freezed == totalEmailsSent + ? _value.totalEmailsSent + : totalEmailsSent // ignore: cast_nullable_to_non_nullable + as int?, + emailsRead: freezed == emailsRead + ? _value.emailsRead + : emailsRead // ignore: cast_nullable_to_non_nullable + as int?, + newLeadsContacted: freezed == newLeadsContacted + ? _value.newLeadsContacted + : newLeadsContacted // ignore: cast_nullable_to_non_nullable + as int?, + leadsReplied: freezed == leadsReplied + ? _value.leadsReplied + : leadsReplied // ignore: cast_nullable_to_non_nullable + as int?, + leadsRead: freezed == leadsRead + ? _value.leadsRead + : leadsRead // ignore: cast_nullable_to_non_nullable + as int?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$CampaignCountImplCopyWith<$Res> + implements $CampaignCountCopyWith<$Res> { + factory _$$CampaignCountImplCopyWith( + _$CampaignCountImpl value, $Res Function(_$CampaignCountImpl) then) = + __$$CampaignCountImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: 'campaign_id') String campaignId, + @JsonKey(name: 'campaign_name') String? campaignName, + @JsonKey(name: 'total_emails_sent') int? totalEmailsSent, + @JsonKey(name: 'emails_read') int? emailsRead, + @JsonKey(name: 'new_leads_contacted') int? newLeadsContacted, + @JsonKey(name: 'leads_replied') int? leadsReplied, + @JsonKey(name: 'leads_read') int? leadsRead}); +} + +/// @nodoc +class __$$CampaignCountImplCopyWithImpl<$Res> + extends _$CampaignCountCopyWithImpl<$Res, _$CampaignCountImpl> + implements _$$CampaignCountImplCopyWith<$Res> { + __$$CampaignCountImplCopyWithImpl( + _$CampaignCountImpl _value, $Res Function(_$CampaignCountImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? campaignId = null, + Object? campaignName = freezed, + Object? totalEmailsSent = freezed, + Object? emailsRead = freezed, + Object? newLeadsContacted = freezed, + Object? leadsReplied = freezed, + Object? leadsRead = freezed, + }) { + return _then(_$CampaignCountImpl( + campaignId: null == campaignId + ? _value.campaignId + : campaignId // ignore: cast_nullable_to_non_nullable + as String, + campaignName: freezed == campaignName + ? _value.campaignName + : campaignName // ignore: cast_nullable_to_non_nullable + as String?, + totalEmailsSent: freezed == totalEmailsSent + ? _value.totalEmailsSent + : totalEmailsSent // ignore: cast_nullable_to_non_nullable + as int?, + emailsRead: freezed == emailsRead + ? _value.emailsRead + : emailsRead // ignore: cast_nullable_to_non_nullable + as int?, + newLeadsContacted: freezed == newLeadsContacted + ? _value.newLeadsContacted + : newLeadsContacted // ignore: cast_nullable_to_non_nullable + as int?, + leadsReplied: freezed == leadsReplied + ? _value.leadsReplied + : leadsReplied // ignore: cast_nullable_to_non_nullable + as int?, + leadsRead: freezed == leadsRead + ? _value.leadsRead + : leadsRead // ignore: cast_nullable_to_non_nullable + as int?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$CampaignCountImpl implements _CampaignCount { + const _$CampaignCountImpl( + {@JsonKey(name: 'campaign_id') required this.campaignId, + @JsonKey(name: 'campaign_name') this.campaignName, + @JsonKey(name: 'total_emails_sent') this.totalEmailsSent, + @JsonKey(name: 'emails_read') this.emailsRead, + @JsonKey(name: 'new_leads_contacted') this.newLeadsContacted, + @JsonKey(name: 'leads_replied') this.leadsReplied, + @JsonKey(name: 'leads_read') this.leadsRead}); + + factory _$CampaignCountImpl.fromJson(Map json) => + _$$CampaignCountImplFromJson(json); + + @override + @JsonKey(name: 'campaign_id') + final String campaignId; + @override + @JsonKey(name: 'campaign_name') + final String? campaignName; + @override + @JsonKey(name: 'total_emails_sent') + final int? totalEmailsSent; + @override + @JsonKey(name: 'emails_read') + final int? emailsRead; + @override + @JsonKey(name: 'new_leads_contacted') + final int? newLeadsContacted; + @override + @JsonKey(name: 'leads_replied') + final int? leadsReplied; + @override + @JsonKey(name: 'leads_read') + final int? leadsRead; + + @override + String toString() { + return 'CampaignCount(campaignId: $campaignId, campaignName: $campaignName, totalEmailsSent: $totalEmailsSent, emailsRead: $emailsRead, newLeadsContacted: $newLeadsContacted, leadsReplied: $leadsReplied, leadsRead: $leadsRead)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CampaignCountImpl && + (identical(other.campaignId, campaignId) || + other.campaignId == campaignId) && + (identical(other.campaignName, campaignName) || + other.campaignName == campaignName) && + (identical(other.totalEmailsSent, totalEmailsSent) || + other.totalEmailsSent == totalEmailsSent) && + (identical(other.emailsRead, emailsRead) || + other.emailsRead == emailsRead) && + (identical(other.newLeadsContacted, newLeadsContacted) || + other.newLeadsContacted == newLeadsContacted) && + (identical(other.leadsReplied, leadsReplied) || + other.leadsReplied == leadsReplied) && + (identical(other.leadsRead, leadsRead) || + other.leadsRead == leadsRead)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, campaignId, campaignName, + totalEmailsSent, emailsRead, newLeadsContacted, leadsReplied, leadsRead); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$CampaignCountImplCopyWith<_$CampaignCountImpl> get copyWith => + __$$CampaignCountImplCopyWithImpl<_$CampaignCountImpl>(this, _$identity); + + @override + Map toJson() { + return _$$CampaignCountImplToJson( + this, + ); + } +} + +abstract class _CampaignCount implements CampaignCount { + const factory _CampaignCount( + {@JsonKey(name: 'campaign_id') required final String campaignId, + @JsonKey(name: 'campaign_name') final String? campaignName, + @JsonKey(name: 'total_emails_sent') final int? totalEmailsSent, + @JsonKey(name: 'emails_read') final int? emailsRead, + @JsonKey(name: 'new_leads_contacted') final int? newLeadsContacted, + @JsonKey(name: 'leads_replied') final int? leadsReplied, + @JsonKey(name: 'leads_read') final int? leadsRead}) = _$CampaignCountImpl; + + factory _CampaignCount.fromJson(Map json) = + _$CampaignCountImpl.fromJson; + + @override + @JsonKey(name: 'campaign_id') + String get campaignId; + @override + @JsonKey(name: 'campaign_name') + String? get campaignName; + @override + @JsonKey(name: 'total_emails_sent') + int? get totalEmailsSent; + @override + @JsonKey(name: 'emails_read') + int? get emailsRead; + @override + @JsonKey(name: 'new_leads_contacted') + int? get newLeadsContacted; + @override + @JsonKey(name: 'leads_replied') + int? get leadsReplied; + @override + @JsonKey(name: 'leads_read') + int? get leadsRead; + @override + @JsonKey(ignore: true) + _$$CampaignCountImplCopyWith<_$CampaignCountImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/models/campaign_count.g.dart b/lib/src/models/campaign_count.g.dart new file mode 100644 index 0000000..99ce346 --- /dev/null +++ b/lib/src/models/campaign_count.g.dart @@ -0,0 +1,29 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'campaign_count.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$CampaignCountImpl _$$CampaignCountImplFromJson(Map json) => + _$CampaignCountImpl( + campaignId: json['campaign_id'] as String, + campaignName: json['campaign_name'] as String?, + totalEmailsSent: json['total_emails_sent'] as int?, + emailsRead: json['emails_read'] as int?, + newLeadsContacted: json['new_leads_contacted'] as int?, + leadsReplied: json['leads_replied'] as int?, + leadsRead: json['leads_read'] as int?, + ); + +Map _$$CampaignCountImplToJson(_$CampaignCountImpl instance) => + { + 'campaign_id': instance.campaignId, + 'campaign_name': instance.campaignName, + 'total_emails_sent': instance.totalEmailsSent, + 'emails_read': instance.emailsRead, + 'new_leads_contacted': instance.newLeadsContacted, + 'leads_replied': instance.leadsReplied, + 'leads_read': instance.leadsRead, + }; diff --git a/lib/src/models/campaign_summary.dart b/lib/src/models/campaign_summary.dart new file mode 100644 index 0000000..8177547 --- /dev/null +++ b/lib/src/models/campaign_summary.dart @@ -0,0 +1,22 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'campaign_summary.freezed.dart'; +part 'campaign_summary.g.dart'; + +@freezed +class CampaignSummary with _$CampaignSummary { + const factory CampaignSummary({ + @JsonKey(name: 'campaign_id') required String campaignId, + @JsonKey(name: 'campaign_name') required String campaignName, + @JsonKey(name: 'total_leads') required int totalLeads, + required int contacted, + @JsonKey(name: 'leads_who_read') required int leadsWhoRead, + @JsonKey(name: 'leads_who_replied') required int leadsWhoReplied, + required int bounced, + required int unsubscribed, + required int completed, + }) = _CampaignSummary; + + factory CampaignSummary.fromJson(Map json) => + _$CampaignSummaryFromJson(json); +} diff --git a/lib/src/models/campaign_summary.freezed.dart b/lib/src/models/campaign_summary.freezed.dart new file mode 100644 index 0000000..c594c70 --- /dev/null +++ b/lib/src/models/campaign_summary.freezed.dart @@ -0,0 +1,349 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'campaign_summary.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +CampaignSummary _$CampaignSummaryFromJson(Map json) { + return _CampaignSummary.fromJson(json); +} + +/// @nodoc +mixin _$CampaignSummary { + @JsonKey(name: 'campaign_id') + String get campaignId => throw _privateConstructorUsedError; + @JsonKey(name: 'campaign_name') + String get campaignName => throw _privateConstructorUsedError; + @JsonKey(name: 'total_leads') + int get totalLeads => throw _privateConstructorUsedError; + int get contacted => throw _privateConstructorUsedError; + @JsonKey(name: 'leads_who_read') + int get leadsWhoRead => throw _privateConstructorUsedError; + @JsonKey(name: 'leads_who_replied') + int get leadsWhoReplied => throw _privateConstructorUsedError; + int get bounced => throw _privateConstructorUsedError; + int get unsubscribed => throw _privateConstructorUsedError; + int get completed => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $CampaignSummaryCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CampaignSummaryCopyWith<$Res> { + factory $CampaignSummaryCopyWith( + CampaignSummary value, $Res Function(CampaignSummary) then) = + _$CampaignSummaryCopyWithImpl<$Res, CampaignSummary>; + @useResult + $Res call( + {@JsonKey(name: 'campaign_id') String campaignId, + @JsonKey(name: 'campaign_name') String campaignName, + @JsonKey(name: 'total_leads') int totalLeads, + int contacted, + @JsonKey(name: 'leads_who_read') int leadsWhoRead, + @JsonKey(name: 'leads_who_replied') int leadsWhoReplied, + int bounced, + int unsubscribed, + int completed}); +} + +/// @nodoc +class _$CampaignSummaryCopyWithImpl<$Res, $Val extends CampaignSummary> + implements $CampaignSummaryCopyWith<$Res> { + _$CampaignSummaryCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? campaignId = null, + Object? campaignName = null, + Object? totalLeads = null, + Object? contacted = null, + Object? leadsWhoRead = null, + Object? leadsWhoReplied = null, + Object? bounced = null, + Object? unsubscribed = null, + Object? completed = null, + }) { + return _then(_value.copyWith( + campaignId: null == campaignId + ? _value.campaignId + : campaignId // ignore: cast_nullable_to_non_nullable + as String, + campaignName: null == campaignName + ? _value.campaignName + : campaignName // ignore: cast_nullable_to_non_nullable + as String, + totalLeads: null == totalLeads + ? _value.totalLeads + : totalLeads // ignore: cast_nullable_to_non_nullable + as int, + contacted: null == contacted + ? _value.contacted + : contacted // ignore: cast_nullable_to_non_nullable + as int, + leadsWhoRead: null == leadsWhoRead + ? _value.leadsWhoRead + : leadsWhoRead // ignore: cast_nullable_to_non_nullable + as int, + leadsWhoReplied: null == leadsWhoReplied + ? _value.leadsWhoReplied + : leadsWhoReplied // ignore: cast_nullable_to_non_nullable + as int, + bounced: null == bounced + ? _value.bounced + : bounced // ignore: cast_nullable_to_non_nullable + as int, + unsubscribed: null == unsubscribed + ? _value.unsubscribed + : unsubscribed // ignore: cast_nullable_to_non_nullable + as int, + completed: null == completed + ? _value.completed + : completed // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$CampaignSummaryImplCopyWith<$Res> + implements $CampaignSummaryCopyWith<$Res> { + factory _$$CampaignSummaryImplCopyWith(_$CampaignSummaryImpl value, + $Res Function(_$CampaignSummaryImpl) then) = + __$$CampaignSummaryImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: 'campaign_id') String campaignId, + @JsonKey(name: 'campaign_name') String campaignName, + @JsonKey(name: 'total_leads') int totalLeads, + int contacted, + @JsonKey(name: 'leads_who_read') int leadsWhoRead, + @JsonKey(name: 'leads_who_replied') int leadsWhoReplied, + int bounced, + int unsubscribed, + int completed}); +} + +/// @nodoc +class __$$CampaignSummaryImplCopyWithImpl<$Res> + extends _$CampaignSummaryCopyWithImpl<$Res, _$CampaignSummaryImpl> + implements _$$CampaignSummaryImplCopyWith<$Res> { + __$$CampaignSummaryImplCopyWithImpl( + _$CampaignSummaryImpl _value, $Res Function(_$CampaignSummaryImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? campaignId = null, + Object? campaignName = null, + Object? totalLeads = null, + Object? contacted = null, + Object? leadsWhoRead = null, + Object? leadsWhoReplied = null, + Object? bounced = null, + Object? unsubscribed = null, + Object? completed = null, + }) { + return _then(_$CampaignSummaryImpl( + campaignId: null == campaignId + ? _value.campaignId + : campaignId // ignore: cast_nullable_to_non_nullable + as String, + campaignName: null == campaignName + ? _value.campaignName + : campaignName // ignore: cast_nullable_to_non_nullable + as String, + totalLeads: null == totalLeads + ? _value.totalLeads + : totalLeads // ignore: cast_nullable_to_non_nullable + as int, + contacted: null == contacted + ? _value.contacted + : contacted // ignore: cast_nullable_to_non_nullable + as int, + leadsWhoRead: null == leadsWhoRead + ? _value.leadsWhoRead + : leadsWhoRead // ignore: cast_nullable_to_non_nullable + as int, + leadsWhoReplied: null == leadsWhoReplied + ? _value.leadsWhoReplied + : leadsWhoReplied // ignore: cast_nullable_to_non_nullable + as int, + bounced: null == bounced + ? _value.bounced + : bounced // ignore: cast_nullable_to_non_nullable + as int, + unsubscribed: null == unsubscribed + ? _value.unsubscribed + : unsubscribed // ignore: cast_nullable_to_non_nullable + as int, + completed: null == completed + ? _value.completed + : completed // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$CampaignSummaryImpl implements _CampaignSummary { + const _$CampaignSummaryImpl( + {@JsonKey(name: 'campaign_id') required this.campaignId, + @JsonKey(name: 'campaign_name') required this.campaignName, + @JsonKey(name: 'total_leads') required this.totalLeads, + required this.contacted, + @JsonKey(name: 'leads_who_read') required this.leadsWhoRead, + @JsonKey(name: 'leads_who_replied') required this.leadsWhoReplied, + required this.bounced, + required this.unsubscribed, + required this.completed}); + + factory _$CampaignSummaryImpl.fromJson(Map json) => + _$$CampaignSummaryImplFromJson(json); + + @override + @JsonKey(name: 'campaign_id') + final String campaignId; + @override + @JsonKey(name: 'campaign_name') + final String campaignName; + @override + @JsonKey(name: 'total_leads') + final int totalLeads; + @override + final int contacted; + @override + @JsonKey(name: 'leads_who_read') + final int leadsWhoRead; + @override + @JsonKey(name: 'leads_who_replied') + final int leadsWhoReplied; + @override + final int bounced; + @override + final int unsubscribed; + @override + final int completed; + + @override + String toString() { + return 'CampaignSummary(campaignId: $campaignId, campaignName: $campaignName, totalLeads: $totalLeads, contacted: $contacted, leadsWhoRead: $leadsWhoRead, leadsWhoReplied: $leadsWhoReplied, bounced: $bounced, unsubscribed: $unsubscribed, completed: $completed)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CampaignSummaryImpl && + (identical(other.campaignId, campaignId) || + other.campaignId == campaignId) && + (identical(other.campaignName, campaignName) || + other.campaignName == campaignName) && + (identical(other.totalLeads, totalLeads) || + other.totalLeads == totalLeads) && + (identical(other.contacted, contacted) || + other.contacted == contacted) && + (identical(other.leadsWhoRead, leadsWhoRead) || + other.leadsWhoRead == leadsWhoRead) && + (identical(other.leadsWhoReplied, leadsWhoReplied) || + other.leadsWhoReplied == leadsWhoReplied) && + (identical(other.bounced, bounced) || other.bounced == bounced) && + (identical(other.unsubscribed, unsubscribed) || + other.unsubscribed == unsubscribed) && + (identical(other.completed, completed) || + other.completed == completed)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + campaignId, + campaignName, + totalLeads, + contacted, + leadsWhoRead, + leadsWhoReplied, + bounced, + unsubscribed, + completed); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$CampaignSummaryImplCopyWith<_$CampaignSummaryImpl> get copyWith => + __$$CampaignSummaryImplCopyWithImpl<_$CampaignSummaryImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$CampaignSummaryImplToJson( + this, + ); + } +} + +abstract class _CampaignSummary implements CampaignSummary { + const factory _CampaignSummary( + {@JsonKey(name: 'campaign_id') required final String campaignId, + @JsonKey(name: 'campaign_name') required final String campaignName, + @JsonKey(name: 'total_leads') required final int totalLeads, + required final int contacted, + @JsonKey(name: 'leads_who_read') required final int leadsWhoRead, + @JsonKey(name: 'leads_who_replied') required final int leadsWhoReplied, + required final int bounced, + required final int unsubscribed, + required final int completed}) = _$CampaignSummaryImpl; + + factory _CampaignSummary.fromJson(Map json) = + _$CampaignSummaryImpl.fromJson; + + @override + @JsonKey(name: 'campaign_id') + String get campaignId; + @override + @JsonKey(name: 'campaign_name') + String get campaignName; + @override + @JsonKey(name: 'total_leads') + int get totalLeads; + @override + int get contacted; + @override + @JsonKey(name: 'leads_who_read') + int get leadsWhoRead; + @override + @JsonKey(name: 'leads_who_replied') + int get leadsWhoReplied; + @override + int get bounced; + @override + int get unsubscribed; + @override + int get completed; + @override + @JsonKey(ignore: true) + _$$CampaignSummaryImplCopyWith<_$CampaignSummaryImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/models/campaign_summary.g.dart b/lib/src/models/campaign_summary.g.dart new file mode 100644 index 0000000..67b2636 --- /dev/null +++ b/lib/src/models/campaign_summary.g.dart @@ -0,0 +1,35 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'campaign_summary.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$CampaignSummaryImpl _$$CampaignSummaryImplFromJson( + Map json) => + _$CampaignSummaryImpl( + campaignId: json['campaign_id'] as String, + campaignName: json['campaign_name'] as String, + totalLeads: json['total_leads'] as int, + contacted: json['contacted'] as int, + leadsWhoRead: json['leads_who_read'] as int, + leadsWhoReplied: json['leads_who_replied'] as int, + bounced: json['bounced'] as int, + unsubscribed: json['unsubscribed'] as int, + completed: json['completed'] as int, + ); + +Map _$$CampaignSummaryImplToJson( + _$CampaignSummaryImpl instance) => + { + 'campaign_id': instance.campaignId, + 'campaign_name': instance.campaignName, + 'total_leads': instance.totalLeads, + 'contacted': instance.contacted, + 'leads_who_read': instance.leadsWhoRead, + 'leads_who_replied': instance.leadsWhoReplied, + 'bounced': instance.bounced, + 'unsubscribed': instance.unsubscribed, + 'completed': instance.completed, + }; diff --git a/lib/src/models/email.dart b/lib/src/models/email.dart new file mode 100644 index 0000000..714db8f --- /dev/null +++ b/lib/src/models/email.dart @@ -0,0 +1,52 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'email.freezed.dart'; +part 'email.g.dart'; + +/// An email in the Instantly API. +@freezed +class Email with _$Email { + /// Default constructor for the email. + const factory Email({ + required String id, + @JsonKey(name: 'message_id') required String messageId, + @JsonKey(name: 'is_unread') required bool isUnread, + String? lead, + @JsonKey(name: 'campaign_id') String? campaignId, + @JsonKey(name: 'from_address_email') required String fromAddressEmail, + @JsonKey(name: 'from_address_json') + required List fromAddressJson, + @JsonKey(name: 'ai_interest_value') double? aiInterestValue, + @JsonKey(name: 'reminder_ts') DateTime? reminderTs, + @JsonKey(name: 'i_status') int? iStatus, + required String subject, + @JsonKey(name: 'timestamp_created') required DateTime timestampCreated, + @JsonKey(name: 'content_preview') String? contentPreview, + @JsonKey(name: 'thread_id') String? threadId, + @JsonKey(name: 'eaccount') String? eaccount, + @JsonKey(name: 'to_address_email_list') List? toAddressEmailList, + @JsonKey(name: 'to_address_json') List? toAddressJson, + @JsonKey(name: 'ue_type') int? ueType, + @JsonKey(name: 'scheduled_at') DateTime? scheduledAt, + @JsonKey(name: 'cc_address_email_list') List? ccAddressEmailList, + @JsonKey(name: 'cc_address_json') List? ccAddressJson, + @JsonKey(name: 'bcc_address_email_list') List? bccAddressEmailList, + }) = _Email; + + /// Create an email from a JSON object. + factory Email.fromJson(Map json) => _$EmailFromJson(json); +} + +/// An email address in the Instantly API. +@freezed +class EmailAddress with _$EmailAddress { + /// Default constructor for the email address. + const factory EmailAddress({ + required String address, + String? name, + }) = _EmailAddress; + + /// Create an email address from a JSON object. + factory EmailAddress.fromJson(Map json) => + _$EmailAddressFromJson(json); +} diff --git a/lib/src/models/email.freezed.dart b/lib/src/models/email.freezed.dart new file mode 100644 index 0000000..cea0800 --- /dev/null +++ b/lib/src/models/email.freezed.dart @@ -0,0 +1,888 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'email.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +Email _$EmailFromJson(Map json) { + return _Email.fromJson(json); +} + +/// @nodoc +mixin _$Email { + String get id => throw _privateConstructorUsedError; + @JsonKey(name: 'message_id') + String get messageId => throw _privateConstructorUsedError; + @JsonKey(name: 'is_unread') + bool get isUnread => throw _privateConstructorUsedError; + String? get lead => throw _privateConstructorUsedError; + @JsonKey(name: 'campaign_id') + String? get campaignId => throw _privateConstructorUsedError; + @JsonKey(name: 'from_address_email') + String get fromAddressEmail => throw _privateConstructorUsedError; + @JsonKey(name: 'from_address_json') + List get fromAddressJson => throw _privateConstructorUsedError; + @JsonKey(name: 'ai_interest_value') + double? get aiInterestValue => throw _privateConstructorUsedError; + @JsonKey(name: 'reminder_ts') + DateTime? get reminderTs => throw _privateConstructorUsedError; + @JsonKey(name: 'i_status') + int? get iStatus => throw _privateConstructorUsedError; + String get subject => throw _privateConstructorUsedError; + @JsonKey(name: 'timestamp_created') + DateTime get timestampCreated => throw _privateConstructorUsedError; + @JsonKey(name: 'content_preview') + String? get contentPreview => throw _privateConstructorUsedError; + @JsonKey(name: 'thread_id') + String? get threadId => throw _privateConstructorUsedError; + @JsonKey(name: 'eaccount') + String? get eaccount => throw _privateConstructorUsedError; + @JsonKey(name: 'to_address_email_list') + List? get toAddressEmailList => throw _privateConstructorUsedError; + @JsonKey(name: 'to_address_json') + List? get toAddressJson => throw _privateConstructorUsedError; + @JsonKey(name: 'ue_type') + int? get ueType => throw _privateConstructorUsedError; + @JsonKey(name: 'scheduled_at') + DateTime? get scheduledAt => throw _privateConstructorUsedError; + @JsonKey(name: 'cc_address_email_list') + List? get ccAddressEmailList => throw _privateConstructorUsedError; + @JsonKey(name: 'cc_address_json') + List? get ccAddressJson => throw _privateConstructorUsedError; + @JsonKey(name: 'bcc_address_email_list') + List? get bccAddressEmailList => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $EmailCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $EmailCopyWith<$Res> { + factory $EmailCopyWith(Email value, $Res Function(Email) then) = + _$EmailCopyWithImpl<$Res, Email>; + @useResult + $Res call( + {String id, + @JsonKey(name: 'message_id') String messageId, + @JsonKey(name: 'is_unread') bool isUnread, + String? lead, + @JsonKey(name: 'campaign_id') String? campaignId, + @JsonKey(name: 'from_address_email') String fromAddressEmail, + @JsonKey(name: 'from_address_json') List fromAddressJson, + @JsonKey(name: 'ai_interest_value') double? aiInterestValue, + @JsonKey(name: 'reminder_ts') DateTime? reminderTs, + @JsonKey(name: 'i_status') int? iStatus, + String subject, + @JsonKey(name: 'timestamp_created') DateTime timestampCreated, + @JsonKey(name: 'content_preview') String? contentPreview, + @JsonKey(name: 'thread_id') String? threadId, + @JsonKey(name: 'eaccount') String? eaccount, + @JsonKey(name: 'to_address_email_list') List? toAddressEmailList, + @JsonKey(name: 'to_address_json') List? toAddressJson, + @JsonKey(name: 'ue_type') int? ueType, + @JsonKey(name: 'scheduled_at') DateTime? scheduledAt, + @JsonKey(name: 'cc_address_email_list') List? ccAddressEmailList, + @JsonKey(name: 'cc_address_json') List? ccAddressJson, + @JsonKey(name: 'bcc_address_email_list') + List? bccAddressEmailList}); +} + +/// @nodoc +class _$EmailCopyWithImpl<$Res, $Val extends Email> + implements $EmailCopyWith<$Res> { + _$EmailCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? messageId = null, + Object? isUnread = null, + Object? lead = freezed, + Object? campaignId = freezed, + Object? fromAddressEmail = null, + Object? fromAddressJson = null, + Object? aiInterestValue = freezed, + Object? reminderTs = freezed, + Object? iStatus = freezed, + Object? subject = null, + Object? timestampCreated = null, + Object? contentPreview = freezed, + Object? threadId = freezed, + Object? eaccount = freezed, + Object? toAddressEmailList = freezed, + Object? toAddressJson = freezed, + Object? ueType = freezed, + Object? scheduledAt = freezed, + Object? ccAddressEmailList = freezed, + Object? ccAddressJson = freezed, + Object? bccAddressEmailList = freezed, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + messageId: null == messageId + ? _value.messageId + : messageId // ignore: cast_nullable_to_non_nullable + as String, + isUnread: null == isUnread + ? _value.isUnread + : isUnread // ignore: cast_nullable_to_non_nullable + as bool, + lead: freezed == lead + ? _value.lead + : lead // ignore: cast_nullable_to_non_nullable + as String?, + campaignId: freezed == campaignId + ? _value.campaignId + : campaignId // ignore: cast_nullable_to_non_nullable + as String?, + fromAddressEmail: null == fromAddressEmail + ? _value.fromAddressEmail + : fromAddressEmail // ignore: cast_nullable_to_non_nullable + as String, + fromAddressJson: null == fromAddressJson + ? _value.fromAddressJson + : fromAddressJson // ignore: cast_nullable_to_non_nullable + as List, + aiInterestValue: freezed == aiInterestValue + ? _value.aiInterestValue + : aiInterestValue // ignore: cast_nullable_to_non_nullable + as double?, + reminderTs: freezed == reminderTs + ? _value.reminderTs + : reminderTs // ignore: cast_nullable_to_non_nullable + as DateTime?, + iStatus: freezed == iStatus + ? _value.iStatus + : iStatus // ignore: cast_nullable_to_non_nullable + as int?, + subject: null == subject + ? _value.subject + : subject // ignore: cast_nullable_to_non_nullable + as String, + timestampCreated: null == timestampCreated + ? _value.timestampCreated + : timestampCreated // ignore: cast_nullable_to_non_nullable + as DateTime, + contentPreview: freezed == contentPreview + ? _value.contentPreview + : contentPreview // ignore: cast_nullable_to_non_nullable + as String?, + threadId: freezed == threadId + ? _value.threadId + : threadId // ignore: cast_nullable_to_non_nullable + as String?, + eaccount: freezed == eaccount + ? _value.eaccount + : eaccount // ignore: cast_nullable_to_non_nullable + as String?, + toAddressEmailList: freezed == toAddressEmailList + ? _value.toAddressEmailList + : toAddressEmailList // ignore: cast_nullable_to_non_nullable + as List?, + toAddressJson: freezed == toAddressJson + ? _value.toAddressJson + : toAddressJson // ignore: cast_nullable_to_non_nullable + as List?, + ueType: freezed == ueType + ? _value.ueType + : ueType // ignore: cast_nullable_to_non_nullable + as int?, + scheduledAt: freezed == scheduledAt + ? _value.scheduledAt + : scheduledAt // ignore: cast_nullable_to_non_nullable + as DateTime?, + ccAddressEmailList: freezed == ccAddressEmailList + ? _value.ccAddressEmailList + : ccAddressEmailList // ignore: cast_nullable_to_non_nullable + as List?, + ccAddressJson: freezed == ccAddressJson + ? _value.ccAddressJson + : ccAddressJson // ignore: cast_nullable_to_non_nullable + as List?, + bccAddressEmailList: freezed == bccAddressEmailList + ? _value.bccAddressEmailList + : bccAddressEmailList // ignore: cast_nullable_to_non_nullable + as List?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$EmailImplCopyWith<$Res> implements $EmailCopyWith<$Res> { + factory _$$EmailImplCopyWith( + _$EmailImpl value, $Res Function(_$EmailImpl) then) = + __$$EmailImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String id, + @JsonKey(name: 'message_id') String messageId, + @JsonKey(name: 'is_unread') bool isUnread, + String? lead, + @JsonKey(name: 'campaign_id') String? campaignId, + @JsonKey(name: 'from_address_email') String fromAddressEmail, + @JsonKey(name: 'from_address_json') List fromAddressJson, + @JsonKey(name: 'ai_interest_value') double? aiInterestValue, + @JsonKey(name: 'reminder_ts') DateTime? reminderTs, + @JsonKey(name: 'i_status') int? iStatus, + String subject, + @JsonKey(name: 'timestamp_created') DateTime timestampCreated, + @JsonKey(name: 'content_preview') String? contentPreview, + @JsonKey(name: 'thread_id') String? threadId, + @JsonKey(name: 'eaccount') String? eaccount, + @JsonKey(name: 'to_address_email_list') List? toAddressEmailList, + @JsonKey(name: 'to_address_json') List? toAddressJson, + @JsonKey(name: 'ue_type') int? ueType, + @JsonKey(name: 'scheduled_at') DateTime? scheduledAt, + @JsonKey(name: 'cc_address_email_list') List? ccAddressEmailList, + @JsonKey(name: 'cc_address_json') List? ccAddressJson, + @JsonKey(name: 'bcc_address_email_list') + List? bccAddressEmailList}); +} + +/// @nodoc +class __$$EmailImplCopyWithImpl<$Res> + extends _$EmailCopyWithImpl<$Res, _$EmailImpl> + implements _$$EmailImplCopyWith<$Res> { + __$$EmailImplCopyWithImpl( + _$EmailImpl _value, $Res Function(_$EmailImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? messageId = null, + Object? isUnread = null, + Object? lead = freezed, + Object? campaignId = freezed, + Object? fromAddressEmail = null, + Object? fromAddressJson = null, + Object? aiInterestValue = freezed, + Object? reminderTs = freezed, + Object? iStatus = freezed, + Object? subject = null, + Object? timestampCreated = null, + Object? contentPreview = freezed, + Object? threadId = freezed, + Object? eaccount = freezed, + Object? toAddressEmailList = freezed, + Object? toAddressJson = freezed, + Object? ueType = freezed, + Object? scheduledAt = freezed, + Object? ccAddressEmailList = freezed, + Object? ccAddressJson = freezed, + Object? bccAddressEmailList = freezed, + }) { + return _then(_$EmailImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + messageId: null == messageId + ? _value.messageId + : messageId // ignore: cast_nullable_to_non_nullable + as String, + isUnread: null == isUnread + ? _value.isUnread + : isUnread // ignore: cast_nullable_to_non_nullable + as bool, + lead: freezed == lead + ? _value.lead + : lead // ignore: cast_nullable_to_non_nullable + as String?, + campaignId: freezed == campaignId + ? _value.campaignId + : campaignId // ignore: cast_nullable_to_non_nullable + as String?, + fromAddressEmail: null == fromAddressEmail + ? _value.fromAddressEmail + : fromAddressEmail // ignore: cast_nullable_to_non_nullable + as String, + fromAddressJson: null == fromAddressJson + ? _value._fromAddressJson + : fromAddressJson // ignore: cast_nullable_to_non_nullable + as List, + aiInterestValue: freezed == aiInterestValue + ? _value.aiInterestValue + : aiInterestValue // ignore: cast_nullable_to_non_nullable + as double?, + reminderTs: freezed == reminderTs + ? _value.reminderTs + : reminderTs // ignore: cast_nullable_to_non_nullable + as DateTime?, + iStatus: freezed == iStatus + ? _value.iStatus + : iStatus // ignore: cast_nullable_to_non_nullable + as int?, + subject: null == subject + ? _value.subject + : subject // ignore: cast_nullable_to_non_nullable + as String, + timestampCreated: null == timestampCreated + ? _value.timestampCreated + : timestampCreated // ignore: cast_nullable_to_non_nullable + as DateTime, + contentPreview: freezed == contentPreview + ? _value.contentPreview + : contentPreview // ignore: cast_nullable_to_non_nullable + as String?, + threadId: freezed == threadId + ? _value.threadId + : threadId // ignore: cast_nullable_to_non_nullable + as String?, + eaccount: freezed == eaccount + ? _value.eaccount + : eaccount // ignore: cast_nullable_to_non_nullable + as String?, + toAddressEmailList: freezed == toAddressEmailList + ? _value._toAddressEmailList + : toAddressEmailList // ignore: cast_nullable_to_non_nullable + as List?, + toAddressJson: freezed == toAddressJson + ? _value._toAddressJson + : toAddressJson // ignore: cast_nullable_to_non_nullable + as List?, + ueType: freezed == ueType + ? _value.ueType + : ueType // ignore: cast_nullable_to_non_nullable + as int?, + scheduledAt: freezed == scheduledAt + ? _value.scheduledAt + : scheduledAt // ignore: cast_nullable_to_non_nullable + as DateTime?, + ccAddressEmailList: freezed == ccAddressEmailList + ? _value._ccAddressEmailList + : ccAddressEmailList // ignore: cast_nullable_to_non_nullable + as List?, + ccAddressJson: freezed == ccAddressJson + ? _value._ccAddressJson + : ccAddressJson // ignore: cast_nullable_to_non_nullable + as List?, + bccAddressEmailList: freezed == bccAddressEmailList + ? _value._bccAddressEmailList + : bccAddressEmailList // ignore: cast_nullable_to_non_nullable + as List?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$EmailImpl implements _Email { + const _$EmailImpl( + {required this.id, + @JsonKey(name: 'message_id') required this.messageId, + @JsonKey(name: 'is_unread') required this.isUnread, + this.lead, + @JsonKey(name: 'campaign_id') this.campaignId, + @JsonKey(name: 'from_address_email') required this.fromAddressEmail, + @JsonKey(name: 'from_address_json') + required final List fromAddressJson, + @JsonKey(name: 'ai_interest_value') this.aiInterestValue, + @JsonKey(name: 'reminder_ts') this.reminderTs, + @JsonKey(name: 'i_status') this.iStatus, + required this.subject, + @JsonKey(name: 'timestamp_created') required this.timestampCreated, + @JsonKey(name: 'content_preview') this.contentPreview, + @JsonKey(name: 'thread_id') this.threadId, + @JsonKey(name: 'eaccount') this.eaccount, + @JsonKey(name: 'to_address_email_list') + final List? toAddressEmailList, + @JsonKey(name: 'to_address_json') final List? toAddressJson, + @JsonKey(name: 'ue_type') this.ueType, + @JsonKey(name: 'scheduled_at') this.scheduledAt, + @JsonKey(name: 'cc_address_email_list') + final List? ccAddressEmailList, + @JsonKey(name: 'cc_address_json') final List? ccAddressJson, + @JsonKey(name: 'bcc_address_email_list') + final List? bccAddressEmailList}) + : _fromAddressJson = fromAddressJson, + _toAddressEmailList = toAddressEmailList, + _toAddressJson = toAddressJson, + _ccAddressEmailList = ccAddressEmailList, + _ccAddressJson = ccAddressJson, + _bccAddressEmailList = bccAddressEmailList; + + factory _$EmailImpl.fromJson(Map json) => + _$$EmailImplFromJson(json); + + @override + final String id; + @override + @JsonKey(name: 'message_id') + final String messageId; + @override + @JsonKey(name: 'is_unread') + final bool isUnread; + @override + final String? lead; + @override + @JsonKey(name: 'campaign_id') + final String? campaignId; + @override + @JsonKey(name: 'from_address_email') + final String fromAddressEmail; + final List _fromAddressJson; + @override + @JsonKey(name: 'from_address_json') + List get fromAddressJson { + if (_fromAddressJson is EqualUnmodifiableListView) return _fromAddressJson; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_fromAddressJson); + } + + @override + @JsonKey(name: 'ai_interest_value') + final double? aiInterestValue; + @override + @JsonKey(name: 'reminder_ts') + final DateTime? reminderTs; + @override + @JsonKey(name: 'i_status') + final int? iStatus; + @override + final String subject; + @override + @JsonKey(name: 'timestamp_created') + final DateTime timestampCreated; + @override + @JsonKey(name: 'content_preview') + final String? contentPreview; + @override + @JsonKey(name: 'thread_id') + final String? threadId; + @override + @JsonKey(name: 'eaccount') + final String? eaccount; + final List? _toAddressEmailList; + @override + @JsonKey(name: 'to_address_email_list') + List? get toAddressEmailList { + final value = _toAddressEmailList; + if (value == null) return null; + if (_toAddressEmailList is EqualUnmodifiableListView) + return _toAddressEmailList; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + final List? _toAddressJson; + @override + @JsonKey(name: 'to_address_json') + List? get toAddressJson { + final value = _toAddressJson; + if (value == null) return null; + if (_toAddressJson is EqualUnmodifiableListView) return _toAddressJson; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + @JsonKey(name: 'ue_type') + final int? ueType; + @override + @JsonKey(name: 'scheduled_at') + final DateTime? scheduledAt; + final List? _ccAddressEmailList; + @override + @JsonKey(name: 'cc_address_email_list') + List? get ccAddressEmailList { + final value = _ccAddressEmailList; + if (value == null) return null; + if (_ccAddressEmailList is EqualUnmodifiableListView) + return _ccAddressEmailList; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + final List? _ccAddressJson; + @override + @JsonKey(name: 'cc_address_json') + List? get ccAddressJson { + final value = _ccAddressJson; + if (value == null) return null; + if (_ccAddressJson is EqualUnmodifiableListView) return _ccAddressJson; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + final List? _bccAddressEmailList; + @override + @JsonKey(name: 'bcc_address_email_list') + List? get bccAddressEmailList { + final value = _bccAddressEmailList; + if (value == null) return null; + if (_bccAddressEmailList is EqualUnmodifiableListView) + return _bccAddressEmailList; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + String toString() { + return 'Email(id: $id, messageId: $messageId, isUnread: $isUnread, lead: $lead, campaignId: $campaignId, fromAddressEmail: $fromAddressEmail, fromAddressJson: $fromAddressJson, aiInterestValue: $aiInterestValue, reminderTs: $reminderTs, iStatus: $iStatus, subject: $subject, timestampCreated: $timestampCreated, contentPreview: $contentPreview, threadId: $threadId, eaccount: $eaccount, toAddressEmailList: $toAddressEmailList, toAddressJson: $toAddressJson, ueType: $ueType, scheduledAt: $scheduledAt, ccAddressEmailList: $ccAddressEmailList, ccAddressJson: $ccAddressJson, bccAddressEmailList: $bccAddressEmailList)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$EmailImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.messageId, messageId) || + other.messageId == messageId) && + (identical(other.isUnread, isUnread) || + other.isUnread == isUnread) && + (identical(other.lead, lead) || other.lead == lead) && + (identical(other.campaignId, campaignId) || + other.campaignId == campaignId) && + (identical(other.fromAddressEmail, fromAddressEmail) || + other.fromAddressEmail == fromAddressEmail) && + const DeepCollectionEquality() + .equals(other._fromAddressJson, _fromAddressJson) && + (identical(other.aiInterestValue, aiInterestValue) || + other.aiInterestValue == aiInterestValue) && + (identical(other.reminderTs, reminderTs) || + other.reminderTs == reminderTs) && + (identical(other.iStatus, iStatus) || other.iStatus == iStatus) && + (identical(other.subject, subject) || other.subject == subject) && + (identical(other.timestampCreated, timestampCreated) || + other.timestampCreated == timestampCreated) && + (identical(other.contentPreview, contentPreview) || + other.contentPreview == contentPreview) && + (identical(other.threadId, threadId) || + other.threadId == threadId) && + (identical(other.eaccount, eaccount) || + other.eaccount == eaccount) && + const DeepCollectionEquality() + .equals(other._toAddressEmailList, _toAddressEmailList) && + const DeepCollectionEquality() + .equals(other._toAddressJson, _toAddressJson) && + (identical(other.ueType, ueType) || other.ueType == ueType) && + (identical(other.scheduledAt, scheduledAt) || + other.scheduledAt == scheduledAt) && + const DeepCollectionEquality() + .equals(other._ccAddressEmailList, _ccAddressEmailList) && + const DeepCollectionEquality() + .equals(other._ccAddressJson, _ccAddressJson) && + const DeepCollectionEquality() + .equals(other._bccAddressEmailList, _bccAddressEmailList)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hashAll([ + runtimeType, + id, + messageId, + isUnread, + lead, + campaignId, + fromAddressEmail, + const DeepCollectionEquality().hash(_fromAddressJson), + aiInterestValue, + reminderTs, + iStatus, + subject, + timestampCreated, + contentPreview, + threadId, + eaccount, + const DeepCollectionEquality().hash(_toAddressEmailList), + const DeepCollectionEquality().hash(_toAddressJson), + ueType, + scheduledAt, + const DeepCollectionEquality().hash(_ccAddressEmailList), + const DeepCollectionEquality().hash(_ccAddressJson), + const DeepCollectionEquality().hash(_bccAddressEmailList) + ]); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$EmailImplCopyWith<_$EmailImpl> get copyWith => + __$$EmailImplCopyWithImpl<_$EmailImpl>(this, _$identity); + + @override + Map toJson() { + return _$$EmailImplToJson( + this, + ); + } +} + +abstract class _Email implements Email { + const factory _Email( + {required final String id, + @JsonKey(name: 'message_id') required final String messageId, + @JsonKey(name: 'is_unread') required final bool isUnread, + final String? lead, + @JsonKey(name: 'campaign_id') final String? campaignId, + @JsonKey(name: 'from_address_email') + required final String fromAddressEmail, + @JsonKey(name: 'from_address_json') + required final List fromAddressJson, + @JsonKey(name: 'ai_interest_value') final double? aiInterestValue, + @JsonKey(name: 'reminder_ts') final DateTime? reminderTs, + @JsonKey(name: 'i_status') final int? iStatus, + required final String subject, + @JsonKey(name: 'timestamp_created') + required final DateTime timestampCreated, + @JsonKey(name: 'content_preview') final String? contentPreview, + @JsonKey(name: 'thread_id') final String? threadId, + @JsonKey(name: 'eaccount') final String? eaccount, + @JsonKey(name: 'to_address_email_list') + final List? toAddressEmailList, + @JsonKey(name: 'to_address_json') final List? toAddressJson, + @JsonKey(name: 'ue_type') final int? ueType, + @JsonKey(name: 'scheduled_at') final DateTime? scheduledAt, + @JsonKey(name: 'cc_address_email_list') + final List? ccAddressEmailList, + @JsonKey(name: 'cc_address_json') final List? ccAddressJson, + @JsonKey(name: 'bcc_address_email_list') + final List? bccAddressEmailList}) = _$EmailImpl; + + factory _Email.fromJson(Map json) = _$EmailImpl.fromJson; + + @override + String get id; + @override + @JsonKey(name: 'message_id') + String get messageId; + @override + @JsonKey(name: 'is_unread') + bool get isUnread; + @override + String? get lead; + @override + @JsonKey(name: 'campaign_id') + String? get campaignId; + @override + @JsonKey(name: 'from_address_email') + String get fromAddressEmail; + @override + @JsonKey(name: 'from_address_json') + List get fromAddressJson; + @override + @JsonKey(name: 'ai_interest_value') + double? get aiInterestValue; + @override + @JsonKey(name: 'reminder_ts') + DateTime? get reminderTs; + @override + @JsonKey(name: 'i_status') + int? get iStatus; + @override + String get subject; + @override + @JsonKey(name: 'timestamp_created') + DateTime get timestampCreated; + @override + @JsonKey(name: 'content_preview') + String? get contentPreview; + @override + @JsonKey(name: 'thread_id') + String? get threadId; + @override + @JsonKey(name: 'eaccount') + String? get eaccount; + @override + @JsonKey(name: 'to_address_email_list') + List? get toAddressEmailList; + @override + @JsonKey(name: 'to_address_json') + List? get toAddressJson; + @override + @JsonKey(name: 'ue_type') + int? get ueType; + @override + @JsonKey(name: 'scheduled_at') + DateTime? get scheduledAt; + @override + @JsonKey(name: 'cc_address_email_list') + List? get ccAddressEmailList; + @override + @JsonKey(name: 'cc_address_json') + List? get ccAddressJson; + @override + @JsonKey(name: 'bcc_address_email_list') + List? get bccAddressEmailList; + @override + @JsonKey(ignore: true) + _$$EmailImplCopyWith<_$EmailImpl> get copyWith => + throw _privateConstructorUsedError; +} + +EmailAddress _$EmailAddressFromJson(Map json) { + return _EmailAddress.fromJson(json); +} + +/// @nodoc +mixin _$EmailAddress { + String get address => throw _privateConstructorUsedError; + String? get name => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $EmailAddressCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $EmailAddressCopyWith<$Res> { + factory $EmailAddressCopyWith( + EmailAddress value, $Res Function(EmailAddress) then) = + _$EmailAddressCopyWithImpl<$Res, EmailAddress>; + @useResult + $Res call({String address, String? name}); +} + +/// @nodoc +class _$EmailAddressCopyWithImpl<$Res, $Val extends EmailAddress> + implements $EmailAddressCopyWith<$Res> { + _$EmailAddressCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? address = null, + Object? name = freezed, + }) { + return _then(_value.copyWith( + address: null == address + ? _value.address + : address // ignore: cast_nullable_to_non_nullable + as String, + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$EmailAddressImplCopyWith<$Res> + implements $EmailAddressCopyWith<$Res> { + factory _$$EmailAddressImplCopyWith( + _$EmailAddressImpl value, $Res Function(_$EmailAddressImpl) then) = + __$$EmailAddressImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String address, String? name}); +} + +/// @nodoc +class __$$EmailAddressImplCopyWithImpl<$Res> + extends _$EmailAddressCopyWithImpl<$Res, _$EmailAddressImpl> + implements _$$EmailAddressImplCopyWith<$Res> { + __$$EmailAddressImplCopyWithImpl( + _$EmailAddressImpl _value, $Res Function(_$EmailAddressImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? address = null, + Object? name = freezed, + }) { + return _then(_$EmailAddressImpl( + address: null == address + ? _value.address + : address // ignore: cast_nullable_to_non_nullable + as String, + name: freezed == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$EmailAddressImpl implements _EmailAddress { + const _$EmailAddressImpl({required this.address, this.name}); + + factory _$EmailAddressImpl.fromJson(Map json) => + _$$EmailAddressImplFromJson(json); + + @override + final String address; + @override + final String? name; + + @override + String toString() { + return 'EmailAddress(address: $address, name: $name)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$EmailAddressImpl && + (identical(other.address, address) || other.address == address) && + (identical(other.name, name) || other.name == name)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, address, name); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$EmailAddressImplCopyWith<_$EmailAddressImpl> get copyWith => + __$$EmailAddressImplCopyWithImpl<_$EmailAddressImpl>(this, _$identity); + + @override + Map toJson() { + return _$$EmailAddressImplToJson( + this, + ); + } +} + +abstract class _EmailAddress implements EmailAddress { + const factory _EmailAddress( + {required final String address, final String? name}) = _$EmailAddressImpl; + + factory _EmailAddress.fromJson(Map json) = + _$EmailAddressImpl.fromJson; + + @override + String get address; + @override + String? get name; + @override + @JsonKey(ignore: true) + _$$EmailAddressImplCopyWith<_$EmailAddressImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/models/email.g.dart b/lib/src/models/email.g.dart new file mode 100644 index 0000000..fb5d9ae --- /dev/null +++ b/lib/src/models/email.g.dart @@ -0,0 +1,86 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'email.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$EmailImpl _$$EmailImplFromJson(Map json) => _$EmailImpl( + id: json['id'] as String, + messageId: json['message_id'] as String, + isUnread: json['is_unread'] as bool, + lead: json['lead'] as String?, + campaignId: json['campaign_id'] as String?, + fromAddressEmail: json['from_address_email'] as String, + fromAddressJson: (json['from_address_json'] as List) + .map((e) => EmailAddress.fromJson(e as Map)) + .toList(), + aiInterestValue: (json['ai_interest_value'] as num?)?.toDouble(), + reminderTs: json['reminder_ts'] == null + ? null + : DateTime.parse(json['reminder_ts'] as String), + iStatus: json['i_status'] as int?, + subject: json['subject'] as String, + timestampCreated: DateTime.parse(json['timestamp_created'] as String), + contentPreview: json['content_preview'] as String?, + threadId: json['thread_id'] as String?, + eaccount: json['eaccount'] as String?, + toAddressEmailList: (json['to_address_email_list'] as List?) + ?.map((e) => e as String) + .toList(), + toAddressJson: (json['to_address_json'] as List?) + ?.map((e) => EmailAddress.fromJson(e as Map)) + .toList(), + ueType: json['ue_type'] as int?, + scheduledAt: json['scheduled_at'] == null + ? null + : DateTime.parse(json['scheduled_at'] as String), + ccAddressEmailList: (json['cc_address_email_list'] as List?) + ?.map((e) => e as String) + .toList(), + ccAddressJson: (json['cc_address_json'] as List?) + ?.map((e) => EmailAddress.fromJson(e as Map)) + .toList(), + bccAddressEmailList: (json['bcc_address_email_list'] as List?) + ?.map((e) => e as String) + .toList(), + ); + +Map _$$EmailImplToJson(_$EmailImpl instance) => + { + 'id': instance.id, + 'message_id': instance.messageId, + 'is_unread': instance.isUnread, + 'lead': instance.lead, + 'campaign_id': instance.campaignId, + 'from_address_email': instance.fromAddressEmail, + 'from_address_json': instance.fromAddressJson, + 'ai_interest_value': instance.aiInterestValue, + 'reminder_ts': instance.reminderTs?.toIso8601String(), + 'i_status': instance.iStatus, + 'subject': instance.subject, + 'timestamp_created': instance.timestampCreated.toIso8601String(), + 'content_preview': instance.contentPreview, + 'thread_id': instance.threadId, + 'eaccount': instance.eaccount, + 'to_address_email_list': instance.toAddressEmailList, + 'to_address_json': instance.toAddressJson, + 'ue_type': instance.ueType, + 'scheduled_at': instance.scheduledAt?.toIso8601String(), + 'cc_address_email_list': instance.ccAddressEmailList, + 'cc_address_json': instance.ccAddressJson, + 'bcc_address_email_list': instance.bccAddressEmailList, + }; + +_$EmailAddressImpl _$$EmailAddressImplFromJson(Map json) => + _$EmailAddressImpl( + address: json['address'] as String, + name: json['name'] as String?, + ); + +Map _$$EmailAddressImplToJson(_$EmailAddressImpl instance) => + { + 'address': instance.address, + 'name': instance.name, + }; diff --git a/lib/src/models/instantly_models.dart b/lib/src/models/instantly_models.dart new file mode 100644 index 0000000..55fb1ac --- /dev/null +++ b/lib/src/models/instantly_models.dart @@ -0,0 +1,9 @@ +export 'account.dart'; +export 'account_status.dart'; +export 'account_vitals.dart'; +export 'campaign.dart'; +export 'campaign_count.dart'; +export 'campaign_summary.dart'; +export 'email.dart'; +export 'lead.dart'; +export 'schedule.dart'; diff --git a/lib/src/models/lead.dart b/lib/src/models/lead.dart new file mode 100644 index 0000000..58e35b0 --- /dev/null +++ b/lib/src/models/lead.dart @@ -0,0 +1,61 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'lead.freezed.dart'; +part 'lead.g.dart'; + +/// A lead in the Instantly API. +@freezed +class Lead with _$Lead { + /// Default constructor for the lead. + const factory Lead({ + required String email, + @JsonKey(name: 'first_name') String? firstName, + @JsonKey(name: 'last_name') String? lastName, + @JsonKey(name: 'company_name') String? companyName, + String? personalization, + String? phone, + String? website, + @JsonKey(name: 'custom_variables') + @CustomVariableConverter() + List? customVariables, + }) = _Lead; + + /// Create a lead from a JSON object. + factory Lead.fromJson(Map json) => _$LeadFromJson(json); +} + +/// A custom variable in the Instantly API. +@freezed +class CustomVariable with _$CustomVariable { + /// Default constructor for the custom variable. + const factory CustomVariable({ + required String key, + required String value, + }) = _CustomVariable; +} + +/// A converter for custom variables. +class CustomVariableConverter + implements JsonConverter, Map> { + /// Default constructor for the custom variable converter. + const CustomVariableConverter(); + + @override + List fromJson(Map json) { + return json.entries + .map( + (entry) => + CustomVariable(key: entry.key, value: entry.value.toString()), + ) + .toList(); + } + + @override + Map toJson(List variables) { + final result = {}; + for (final variable in variables) { + result[variable.key] = variable.value; + } + return result; + } +} diff --git a/lib/src/models/lead.freezed.dart b/lib/src/models/lead.freezed.dart new file mode 100644 index 0000000..70de335 --- /dev/null +++ b/lib/src/models/lead.freezed.dart @@ -0,0 +1,472 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'lead.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +Lead _$LeadFromJson(Map json) { + return _Lead.fromJson(json); +} + +/// @nodoc +mixin _$Lead { + String get email => throw _privateConstructorUsedError; + @JsonKey(name: 'first_name') + String? get firstName => throw _privateConstructorUsedError; + @JsonKey(name: 'last_name') + String? get lastName => throw _privateConstructorUsedError; + @JsonKey(name: 'company_name') + String? get companyName => throw _privateConstructorUsedError; + String? get personalization => throw _privateConstructorUsedError; + String? get phone => throw _privateConstructorUsedError; + String? get website => throw _privateConstructorUsedError; + @JsonKey(name: 'custom_variables') + @CustomVariableConverter() + List? get customVariables => + throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $LeadCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $LeadCopyWith<$Res> { + factory $LeadCopyWith(Lead value, $Res Function(Lead) then) = + _$LeadCopyWithImpl<$Res, Lead>; + @useResult + $Res call( + {String email, + @JsonKey(name: 'first_name') String? firstName, + @JsonKey(name: 'last_name') String? lastName, + @JsonKey(name: 'company_name') String? companyName, + String? personalization, + String? phone, + String? website, + @JsonKey(name: 'custom_variables') + @CustomVariableConverter() + List? customVariables}); +} + +/// @nodoc +class _$LeadCopyWithImpl<$Res, $Val extends Lead> + implements $LeadCopyWith<$Res> { + _$LeadCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? email = null, + Object? firstName = freezed, + Object? lastName = freezed, + Object? companyName = freezed, + Object? personalization = freezed, + Object? phone = freezed, + Object? website = freezed, + Object? customVariables = freezed, + }) { + return _then(_value.copyWith( + email: null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + firstName: freezed == firstName + ? _value.firstName + : firstName // ignore: cast_nullable_to_non_nullable + as String?, + lastName: freezed == lastName + ? _value.lastName + : lastName // ignore: cast_nullable_to_non_nullable + as String?, + companyName: freezed == companyName + ? _value.companyName + : companyName // ignore: cast_nullable_to_non_nullable + as String?, + personalization: freezed == personalization + ? _value.personalization + : personalization // ignore: cast_nullable_to_non_nullable + as String?, + phone: freezed == phone + ? _value.phone + : phone // ignore: cast_nullable_to_non_nullable + as String?, + website: freezed == website + ? _value.website + : website // ignore: cast_nullable_to_non_nullable + as String?, + customVariables: freezed == customVariables + ? _value.customVariables + : customVariables // ignore: cast_nullable_to_non_nullable + as List?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$LeadImplCopyWith<$Res> implements $LeadCopyWith<$Res> { + factory _$$LeadImplCopyWith( + _$LeadImpl value, $Res Function(_$LeadImpl) then) = + __$$LeadImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String email, + @JsonKey(name: 'first_name') String? firstName, + @JsonKey(name: 'last_name') String? lastName, + @JsonKey(name: 'company_name') String? companyName, + String? personalization, + String? phone, + String? website, + @JsonKey(name: 'custom_variables') + @CustomVariableConverter() + List? customVariables}); +} + +/// @nodoc +class __$$LeadImplCopyWithImpl<$Res> + extends _$LeadCopyWithImpl<$Res, _$LeadImpl> + implements _$$LeadImplCopyWith<$Res> { + __$$LeadImplCopyWithImpl(_$LeadImpl _value, $Res Function(_$LeadImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? email = null, + Object? firstName = freezed, + Object? lastName = freezed, + Object? companyName = freezed, + Object? personalization = freezed, + Object? phone = freezed, + Object? website = freezed, + Object? customVariables = freezed, + }) { + return _then(_$LeadImpl( + email: null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + firstName: freezed == firstName + ? _value.firstName + : firstName // ignore: cast_nullable_to_non_nullable + as String?, + lastName: freezed == lastName + ? _value.lastName + : lastName // ignore: cast_nullable_to_non_nullable + as String?, + companyName: freezed == companyName + ? _value.companyName + : companyName // ignore: cast_nullable_to_non_nullable + as String?, + personalization: freezed == personalization + ? _value.personalization + : personalization // ignore: cast_nullable_to_non_nullable + as String?, + phone: freezed == phone + ? _value.phone + : phone // ignore: cast_nullable_to_non_nullable + as String?, + website: freezed == website + ? _value.website + : website // ignore: cast_nullable_to_non_nullable + as String?, + customVariables: freezed == customVariables + ? _value._customVariables + : customVariables // ignore: cast_nullable_to_non_nullable + as List?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$LeadImpl implements _Lead { + const _$LeadImpl( + {required this.email, + @JsonKey(name: 'first_name') this.firstName, + @JsonKey(name: 'last_name') this.lastName, + @JsonKey(name: 'company_name') this.companyName, + this.personalization, + this.phone, + this.website, + @JsonKey(name: 'custom_variables') + @CustomVariableConverter() + final List? customVariables}) + : _customVariables = customVariables; + + factory _$LeadImpl.fromJson(Map json) => + _$$LeadImplFromJson(json); + + @override + final String email; + @override + @JsonKey(name: 'first_name') + final String? firstName; + @override + @JsonKey(name: 'last_name') + final String? lastName; + @override + @JsonKey(name: 'company_name') + final String? companyName; + @override + final String? personalization; + @override + final String? phone; + @override + final String? website; + final List? _customVariables; + @override + @JsonKey(name: 'custom_variables') + @CustomVariableConverter() + List? get customVariables { + final value = _customVariables; + if (value == null) return null; + if (_customVariables is EqualUnmodifiableListView) return _customVariables; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + String toString() { + return 'Lead(email: $email, firstName: $firstName, lastName: $lastName, companyName: $companyName, personalization: $personalization, phone: $phone, website: $website, customVariables: $customVariables)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$LeadImpl && + (identical(other.email, email) || other.email == email) && + (identical(other.firstName, firstName) || + other.firstName == firstName) && + (identical(other.lastName, lastName) || + other.lastName == lastName) && + (identical(other.companyName, companyName) || + other.companyName == companyName) && + (identical(other.personalization, personalization) || + other.personalization == personalization) && + (identical(other.phone, phone) || other.phone == phone) && + (identical(other.website, website) || other.website == website) && + const DeepCollectionEquality() + .equals(other._customVariables, _customVariables)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + email, + firstName, + lastName, + companyName, + personalization, + phone, + website, + const DeepCollectionEquality().hash(_customVariables)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$LeadImplCopyWith<_$LeadImpl> get copyWith => + __$$LeadImplCopyWithImpl<_$LeadImpl>(this, _$identity); + + @override + Map toJson() { + return _$$LeadImplToJson( + this, + ); + } +} + +abstract class _Lead implements Lead { + const factory _Lead( + {required final String email, + @JsonKey(name: 'first_name') final String? firstName, + @JsonKey(name: 'last_name') final String? lastName, + @JsonKey(name: 'company_name') final String? companyName, + final String? personalization, + final String? phone, + final String? website, + @JsonKey(name: 'custom_variables') + @CustomVariableConverter() + final List? customVariables}) = _$LeadImpl; + + factory _Lead.fromJson(Map json) = _$LeadImpl.fromJson; + + @override + String get email; + @override + @JsonKey(name: 'first_name') + String? get firstName; + @override + @JsonKey(name: 'last_name') + String? get lastName; + @override + @JsonKey(name: 'company_name') + String? get companyName; + @override + String? get personalization; + @override + String? get phone; + @override + String? get website; + @override + @JsonKey(name: 'custom_variables') + @CustomVariableConverter() + List? get customVariables; + @override + @JsonKey(ignore: true) + _$$LeadImplCopyWith<_$LeadImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$CustomVariable { + String get key => throw _privateConstructorUsedError; + String get value => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $CustomVariableCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CustomVariableCopyWith<$Res> { + factory $CustomVariableCopyWith( + CustomVariable value, $Res Function(CustomVariable) then) = + _$CustomVariableCopyWithImpl<$Res, CustomVariable>; + @useResult + $Res call({String key, String value}); +} + +/// @nodoc +class _$CustomVariableCopyWithImpl<$Res, $Val extends CustomVariable> + implements $CustomVariableCopyWith<$Res> { + _$CustomVariableCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? key = null, + Object? value = null, + }) { + return _then(_value.copyWith( + key: null == key + ? _value.key + : key // ignore: cast_nullable_to_non_nullable + as String, + value: null == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$CustomVariableImplCopyWith<$Res> + implements $CustomVariableCopyWith<$Res> { + factory _$$CustomVariableImplCopyWith(_$CustomVariableImpl value, + $Res Function(_$CustomVariableImpl) then) = + __$$CustomVariableImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String key, String value}); +} + +/// @nodoc +class __$$CustomVariableImplCopyWithImpl<$Res> + extends _$CustomVariableCopyWithImpl<$Res, _$CustomVariableImpl> + implements _$$CustomVariableImplCopyWith<$Res> { + __$$CustomVariableImplCopyWithImpl( + _$CustomVariableImpl _value, $Res Function(_$CustomVariableImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? key = null, + Object? value = null, + }) { + return _then(_$CustomVariableImpl( + key: null == key + ? _value.key + : key // ignore: cast_nullable_to_non_nullable + as String, + value: null == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$CustomVariableImpl implements _CustomVariable { + const _$CustomVariableImpl({required this.key, required this.value}); + + @override + final String key; + @override + final String value; + + @override + String toString() { + return 'CustomVariable(key: $key, value: $value)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CustomVariableImpl && + (identical(other.key, key) || other.key == key) && + (identical(other.value, value) || other.value == value)); + } + + @override + int get hashCode => Object.hash(runtimeType, key, value); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$CustomVariableImplCopyWith<_$CustomVariableImpl> get copyWith => + __$$CustomVariableImplCopyWithImpl<_$CustomVariableImpl>( + this, _$identity); +} + +abstract class _CustomVariable implements CustomVariable { + const factory _CustomVariable( + {required final String key, + required final String value}) = _$CustomVariableImpl; + + @override + String get key; + @override + String get value; + @override + @JsonKey(ignore: true) + _$$CustomVariableImplCopyWith<_$CustomVariableImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/models/lead.g.dart b/lib/src/models/lead.g.dart new file mode 100644 index 0000000..64e65dd --- /dev/null +++ b/lib/src/models/lead.g.dart @@ -0,0 +1,47 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'lead.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$LeadImpl _$$LeadImplFromJson(Map json) => _$LeadImpl( + email: json['email'] as String, + firstName: json['first_name'] as String?, + lastName: json['last_name'] as String?, + companyName: json['company_name'] as String?, + personalization: json['personalization'] as String?, + phone: json['phone'] as String?, + website: json['website'] as String?, + customVariables: + _$JsonConverterFromJson, List>( + json['custom_variables'], + const CustomVariableConverter().fromJson), + ); + +Map _$$LeadImplToJson(_$LeadImpl instance) => + { + 'email': instance.email, + 'first_name': instance.firstName, + 'last_name': instance.lastName, + 'company_name': instance.companyName, + 'personalization': instance.personalization, + 'phone': instance.phone, + 'website': instance.website, + 'custom_variables': + _$JsonConverterToJson, List>( + instance.customVariables, const CustomVariableConverter().toJson), + }; + +Value? _$JsonConverterFromJson( + Object? json, + Value? Function(Json json) fromJson, +) => + json == null ? null : fromJson(json as Json); + +Json? _$JsonConverterToJson( + Value? value, + Json? Function(Value value) toJson, +) => + value == null ? null : toJson(value); diff --git a/lib/src/models/schedule.dart b/lib/src/models/schedule.dart new file mode 100644 index 0000000..a1eb947 --- /dev/null +++ b/lib/src/models/schedule.dart @@ -0,0 +1,27 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'schedule.freezed.dart'; +part 'schedule.g.dart'; + +@freezed +class Schedule with _$Schedule { + const factory Schedule({ + required String name, + required Map days, + required String timezone, + required Timing timing, + }) = _Schedule; + + factory Schedule.fromJson(Map json) => + _$ScheduleFromJson(json); +} + +@freezed +class Timing with _$Timing { + const factory Timing({ + required String from, + required String to, + }) = _Timing; + + factory Timing.fromJson(Map json) => _$TimingFromJson(json); +} diff --git a/lib/src/models/schedule.freezed.dart b/lib/src/models/schedule.freezed.dart new file mode 100644 index 0000000..166d845 --- /dev/null +++ b/lib/src/models/schedule.freezed.dart @@ -0,0 +1,379 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'schedule.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +Schedule _$ScheduleFromJson(Map json) { + return _Schedule.fromJson(json); +} + +/// @nodoc +mixin _$Schedule { + String get name => throw _privateConstructorUsedError; + Map get days => throw _privateConstructorUsedError; + String get timezone => throw _privateConstructorUsedError; + Timing get timing => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $ScheduleCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ScheduleCopyWith<$Res> { + factory $ScheduleCopyWith(Schedule value, $Res Function(Schedule) then) = + _$ScheduleCopyWithImpl<$Res, Schedule>; + @useResult + $Res call( + {String name, Map days, String timezone, Timing timing}); + + $TimingCopyWith<$Res> get timing; +} + +/// @nodoc +class _$ScheduleCopyWithImpl<$Res, $Val extends Schedule> + implements $ScheduleCopyWith<$Res> { + _$ScheduleCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = null, + Object? days = null, + Object? timezone = null, + Object? timing = null, + }) { + return _then(_value.copyWith( + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + days: null == days + ? _value.days + : days // ignore: cast_nullable_to_non_nullable + as Map, + timezone: null == timezone + ? _value.timezone + : timezone // ignore: cast_nullable_to_non_nullable + as String, + timing: null == timing + ? _value.timing + : timing // ignore: cast_nullable_to_non_nullable + as Timing, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $TimingCopyWith<$Res> get timing { + return $TimingCopyWith<$Res>(_value.timing, (value) { + return _then(_value.copyWith(timing: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$ScheduleImplCopyWith<$Res> + implements $ScheduleCopyWith<$Res> { + factory _$$ScheduleImplCopyWith( + _$ScheduleImpl value, $Res Function(_$ScheduleImpl) then) = + __$$ScheduleImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String name, Map days, String timezone, Timing timing}); + + @override + $TimingCopyWith<$Res> get timing; +} + +/// @nodoc +class __$$ScheduleImplCopyWithImpl<$Res> + extends _$ScheduleCopyWithImpl<$Res, _$ScheduleImpl> + implements _$$ScheduleImplCopyWith<$Res> { + __$$ScheduleImplCopyWithImpl( + _$ScheduleImpl _value, $Res Function(_$ScheduleImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = null, + Object? days = null, + Object? timezone = null, + Object? timing = null, + }) { + return _then(_$ScheduleImpl( + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + days: null == days + ? _value._days + : days // ignore: cast_nullable_to_non_nullable + as Map, + timezone: null == timezone + ? _value.timezone + : timezone // ignore: cast_nullable_to_non_nullable + as String, + timing: null == timing + ? _value.timing + : timing // ignore: cast_nullable_to_non_nullable + as Timing, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ScheduleImpl implements _Schedule { + const _$ScheduleImpl( + {required this.name, + required final Map days, + required this.timezone, + required this.timing}) + : _days = days; + + factory _$ScheduleImpl.fromJson(Map json) => + _$$ScheduleImplFromJson(json); + + @override + final String name; + final Map _days; + @override + Map get days { + if (_days is EqualUnmodifiableMapView) return _days; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_days); + } + + @override + final String timezone; + @override + final Timing timing; + + @override + String toString() { + return 'Schedule(name: $name, days: $days, timezone: $timezone, timing: $timing)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ScheduleImpl && + (identical(other.name, name) || other.name == name) && + const DeepCollectionEquality().equals(other._days, _days) && + (identical(other.timezone, timezone) || + other.timezone == timezone) && + (identical(other.timing, timing) || other.timing == timing)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, name, + const DeepCollectionEquality().hash(_days), timezone, timing); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ScheduleImplCopyWith<_$ScheduleImpl> get copyWith => + __$$ScheduleImplCopyWithImpl<_$ScheduleImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ScheduleImplToJson( + this, + ); + } +} + +abstract class _Schedule implements Schedule { + const factory _Schedule( + {required final String name, + required final Map days, + required final String timezone, + required final Timing timing}) = _$ScheduleImpl; + + factory _Schedule.fromJson(Map json) = + _$ScheduleImpl.fromJson; + + @override + String get name; + @override + Map get days; + @override + String get timezone; + @override + Timing get timing; + @override + @JsonKey(ignore: true) + _$$ScheduleImplCopyWith<_$ScheduleImpl> get copyWith => + throw _privateConstructorUsedError; +} + +Timing _$TimingFromJson(Map json) { + return _Timing.fromJson(json); +} + +/// @nodoc +mixin _$Timing { + String get from => throw _privateConstructorUsedError; + String get to => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $TimingCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TimingCopyWith<$Res> { + factory $TimingCopyWith(Timing value, $Res Function(Timing) then) = + _$TimingCopyWithImpl<$Res, Timing>; + @useResult + $Res call({String from, String to}); +} + +/// @nodoc +class _$TimingCopyWithImpl<$Res, $Val extends Timing> + implements $TimingCopyWith<$Res> { + _$TimingCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? from = null, + Object? to = null, + }) { + return _then(_value.copyWith( + from: null == from + ? _value.from + : from // ignore: cast_nullable_to_non_nullable + as String, + to: null == to + ? _value.to + : to // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$TimingImplCopyWith<$Res> implements $TimingCopyWith<$Res> { + factory _$$TimingImplCopyWith( + _$TimingImpl value, $Res Function(_$TimingImpl) then) = + __$$TimingImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String from, String to}); +} + +/// @nodoc +class __$$TimingImplCopyWithImpl<$Res> + extends _$TimingCopyWithImpl<$Res, _$TimingImpl> + implements _$$TimingImplCopyWith<$Res> { + __$$TimingImplCopyWithImpl( + _$TimingImpl _value, $Res Function(_$TimingImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? from = null, + Object? to = null, + }) { + return _then(_$TimingImpl( + from: null == from + ? _value.from + : from // ignore: cast_nullable_to_non_nullable + as String, + to: null == to + ? _value.to + : to // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$TimingImpl implements _Timing { + const _$TimingImpl({required this.from, required this.to}); + + factory _$TimingImpl.fromJson(Map json) => + _$$TimingImplFromJson(json); + + @override + final String from; + @override + final String to; + + @override + String toString() { + return 'Timing(from: $from, to: $to)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$TimingImpl && + (identical(other.from, from) || other.from == from) && + (identical(other.to, to) || other.to == to)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, from, to); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$TimingImplCopyWith<_$TimingImpl> get copyWith => + __$$TimingImplCopyWithImpl<_$TimingImpl>(this, _$identity); + + @override + Map toJson() { + return _$$TimingImplToJson( + this, + ); + } +} + +abstract class _Timing implements Timing { + const factory _Timing( + {required final String from, required final String to}) = _$TimingImpl; + + factory _Timing.fromJson(Map json) = _$TimingImpl.fromJson; + + @override + String get from; + @override + String get to; + @override + @JsonKey(ignore: true) + _$$TimingImplCopyWith<_$TimingImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/models/schedule.g.dart b/lib/src/models/schedule.g.dart new file mode 100644 index 0000000..663daf8 --- /dev/null +++ b/lib/src/models/schedule.g.dart @@ -0,0 +1,34 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'schedule.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$ScheduleImpl _$$ScheduleImplFromJson(Map json) => + _$ScheduleImpl( + name: json['name'] as String, + days: Map.from(json['days'] as Map), + timezone: json['timezone'] as String, + timing: Timing.fromJson(json['timing'] as Map), + ); + +Map _$$ScheduleImplToJson(_$ScheduleImpl instance) => + { + 'name': instance.name, + 'days': instance.days, + 'timezone': instance.timezone, + 'timing': instance.timing, + }; + +_$TimingImpl _$$TimingImplFromJson(Map json) => _$TimingImpl( + from: json['from'] as String, + to: json['to'] as String, + ); + +Map _$$TimingImplToJson(_$TimingImpl instance) => + { + 'from': instance.from, + 'to': instance.to, + }; diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..a4c1603 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,19 @@ +name: instantly_sdk +description: A Very Good Project created by Very Good CLI. +version: 0.1.0+1 +publish_to: none + +environment: + sdk: ">=3.0.0 <4.0.0" + +dev_dependencies: + build_runner: ^2.4.8 + freezed: ^2.4.7 + json_serializable: ^6.7.1 + mocktail: ^1.0.0 + test: ^1.19.2 + very_good_analysis: ^5.1.0 +dependencies: + dio: ^5.4.1 + freezed_annotation: ^2.4.1 + json_annotation: ^4.8.1