unisender-ruby 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +89 -0
- data/CONTRIBUTING.md +10 -1
- data/README.md +55 -112
- data/docs/api.md +395 -210
- data/docs/execution.md +89 -0
- data/docs/import-recovery.md +41 -0
- data/docs/live-contracts.md +34 -0
- data/docs/migration-0.2.md +129 -0
- data/docs/rails.md +248 -0
- data/docs/releases.md +4 -4
- data/docs/testing.md +83 -0
- data/docs/usage.md +144 -0
- data/docs/webhooks.md +41 -0
- data/examples/campaign.rb +5 -6
- data/examples/campaign_lifecycle.rb +28 -0
- data/examples/check_connection.rb +1 -1
- data/examples/events.rb +1 -1
- data/examples/export.rb +20 -6
- data/examples/import.rb +3 -2
- data/examples/import_recovery.rb +70 -0
- data/examples/quickstart.rb +1 -1
- data/examples/subscribe.rb +2 -2
- data/lib/unisender/acceptance.rb +104 -0
- data/lib/unisender/attachment.rb +47 -0
- data/lib/unisender/batch_report.rb +115 -0
- data/lib/unisender/batch_summary.rb +87 -0
- data/lib/unisender/batches.rb +41 -12
- data/lib/unisender/campaign_workflow.rb +72 -0
- data/lib/unisender/client.rb +65 -33
- data/lib/unisender/client_configuration.rb +50 -0
- data/lib/unisender/client_execution.rb +43 -0
- data/lib/unisender/client_state.rb +31 -0
- data/lib/unisender/client_validation.rb +97 -0
- data/lib/unisender/configuration.rb +151 -0
- data/lib/unisender/contact_records.rb +251 -0
- data/lib/unisender/diagnostic_urls.rb +68 -0
- data/lib/unisender/diagnostics.rb +83 -0
- data/lib/unisender/download_target.rb +61 -0
- data/lib/unisender/download_transfer.rb +43 -0
- data/lib/unisender/downloader.rb +99 -0
- data/lib/unisender/error_diagnostics.rb +83 -0
- data/lib/unisender/errors.rb +125 -8
- data/lib/unisender/event_batches.rb +40 -0
- data/lib/unisender/event_payload.rb +50 -22
- data/lib/unisender/events.rb +21 -5
- data/lib/unisender/execution_context.rb +114 -0
- data/lib/unisender/form.rb +20 -12
- data/lib/unisender/helpers.rb +70 -10
- data/lib/unisender/hooks.rb +79 -0
- data/lib/unisender/import_cells.rb +62 -0
- data/lib/unisender/input_types.rb +30 -0
- data/lib/unisender/inputs.rb +262 -0
- data/lib/unisender/iteration.rb +15 -0
- data/lib/unisender/iterators.rb +60 -0
- data/lib/unisender/mail_inputs.rb +37 -0
- data/lib/unisender/named_inputs.rb +52 -0
- data/lib/unisender/observation.rb +30 -0
- data/lib/unisender/operation_contracts.rb +106 -0
- data/lib/unisender/operations/contacts_1.rb +4 -3
- data/lib/unisender/operations/contacts_2.rb +23 -4
- data/lib/unisender/operations/messages_1.rb +7 -4
- data/lib/unisender/operations/messages_2.rb +8 -3
- data/lib/unisender/operations/messages_3.rb +1 -1
- data/lib/unisender/operations/notes_1.rb +1 -1
- data/lib/unisender/operations/statistics_1.rb +3 -3
- data/lib/unisender/operations/templates_1.rb +2 -2
- data/lib/unisender/outcomes.rb +320 -0
- data/lib/unisender/page_response.rb +48 -0
- data/lib/unisender/paginated_operations.rb +43 -2
- data/lib/unisender/pagination.rb +53 -20
- data/lib/unisender/persistent_transport.rb +104 -0
- data/lib/unisender/rate_limiter.rb +72 -0
- data/lib/unisender/record.rb +210 -0
- data/lib/unisender/record_rows.rb +69 -0
- data/lib/unisender/records.rb +614 -0
- data/lib/unisender/request_execution.rb +108 -0
- data/lib/unisender/response.rb +13 -10
- data/lib/unisender/result_registry.rb +72 -0
- data/lib/unisender/results.rb +105 -0
- data/lib/unisender/retry_policy.rb +10 -16
- data/lib/unisender/serialization.rb +54 -0
- data/lib/unisender/statistic_records.rb +129 -0
- data/lib/unisender/task_response.rb +85 -0
- data/lib/unisender/task_waiter.rb +25 -11
- data/lib/unisender/testing/assertions.rb +48 -0
- data/lib/unisender/testing/fixtures.rb +24 -0
- data/lib/unisender/testing.rb +91 -0
- data/lib/unisender/transport.rb +17 -9
- data/lib/unisender/validation.rb +11 -9
- data/lib/unisender/version.rb +1 -1
- data/lib/unisender/webhooks/tokens.rb +38 -0
- data/lib/unisender/webhooks.rb +230 -0
- data/lib/unisender.rb +42 -0
- data/sig/acceptance.rbs +30 -0
- data/sig/attachment.rbs +15 -0
- data/sig/batch_summary.rbs +38 -0
- data/sig/campaign_workflow.rbs +20 -0
- data/sig/configuration.rbs +62 -0
- data/sig/connection_controls.rbs +55 -0
- data/sig/diagnostics.rbs +37 -0
- data/sig/domain_records.rbs +96 -0
- data/sig/downloads.rbs +53 -0
- data/sig/execution.rbs +52 -0
- data/sig/execution_context.rbs +46 -0
- data/sig/hooks.rbs +18 -0
- data/sig/inputs.rbs +84 -0
- data/sig/iterators.rbs +11 -0
- data/sig/mail_inputs.rbs +8 -0
- data/sig/manifest.yaml +11 -0
- data/sig/operation_contracts.rbs +28 -0
- data/sig/operations.rbs +73 -69
- data/sig/outcomes.rbs +90 -0
- data/sig/record.rbs +77 -0
- data/sig/records.rbs +182 -0
- data/sig/serialization.rbs +13 -0
- data/sig/tasks.rbs +26 -0
- data/sig/testing.rbs +54 -0
- data/sig/unisender.rbs +128 -39
- data/sig/webhooks.rbs +55 -0
- metadata +84 -3
data/sig/operations.rbs
CHANGED
|
@@ -1,78 +1,82 @@
|
|
|
1
1
|
module Unisender
|
|
2
2
|
type id = String | Integer
|
|
3
3
|
type flag = bool | 0 | 1
|
|
4
|
-
type
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
type
|
|
9
|
-
type
|
|
10
|
-
type
|
|
4
|
+
type contact_type = :email | :phone | "email" | "phone"
|
|
5
|
+
type template_type = :user | :system | "user" | "system"
|
|
6
|
+
type note_order = :asc | :desc | "ASC" | "DESC" | "asc" | "desc"
|
|
7
|
+
type note_field = :created_at | :updated_at | :pinned_at | "created_at" | "updated_at" | "pinned_at"
|
|
8
|
+
type list = List
|
|
9
|
+
type list_created = IdentifierRecord
|
|
10
|
+
type subscription = Subscription
|
|
11
|
+
type message_created = MessageCreated
|
|
12
|
+
type campaign_created = CampaignCreated
|
|
13
|
+
type task_created = TaskResult
|
|
14
|
+
type task_completed = TaskResult
|
|
11
15
|
|
|
12
|
-
type object =
|
|
13
|
-
type objects = Array[
|
|
14
|
-
type contact_count =
|
|
15
|
-
type total_contacts =
|
|
16
|
-
type delivery_status =
|
|
17
|
-
type message_version =
|
|
18
|
-
type note =
|
|
19
|
-
type event_accepted =
|
|
16
|
+
type object = Record
|
|
17
|
+
type objects = Array[Record]
|
|
18
|
+
type contact_count = ContactCount
|
|
19
|
+
type total_contacts = TotalContacts
|
|
20
|
+
type delivery_status = Status
|
|
21
|
+
type message_version = MessageVersion
|
|
22
|
+
type note = Note
|
|
23
|
+
type event_accepted = Record
|
|
20
24
|
|
|
21
25
|
class Client
|
|
22
|
-
def create_list: (title: String, ?before_subscribe_url: String | nil, ?after_subscribe_url: String | nil, ?sub_user_rights: params | nil) ->
|
|
23
|
-
def delete_list: (list_id: id) ->
|
|
24
|
-
def exclude: (contact_type:
|
|
25
|
-
def export_contacts: (?notify_url: String | nil, ?list_id: id | nil, ?field_names: Array[String] | nil, ?email: String | nil, ?phone: String | nil, ?tag: String | nil, ?email_status: String | nil, ?phone_status: String | nil, ?contact_status: String | nil) ->
|
|
26
|
-
def get_contact_count: (list_id: id, params: params) ->
|
|
27
|
-
def get_lists: () ->
|
|
28
|
-
def get_total_contacts_count: (login: String) ->
|
|
29
|
-
def import_contacts: (field_names: Array[String]
|
|
30
|
-
def subscribe: (list_ids: String | Array[id], fields: params
|
|
31
|
-
def update_list: (list_id: id, title: String, ?before_subscribe_url: String | nil, ?after_subscribe_url: String | nil, ?sub_user_rights: params | nil) ->
|
|
26
|
+
def create_list: (title: String, ?before_subscribe_url: String | nil, ?after_subscribe_url: String | nil, ?sub_user_rights: params | nil) -> IdentifierRecordResponse
|
|
27
|
+
def delete_list: (list_id: id) -> ObjectResponse[Record]
|
|
28
|
+
def exclude: (?contact_type: contact_type?, ?contact: String?, ?email: String?, ?phone: String?, ?list_ids: String | Array[id] | nil) -> ObjectResponse[Record]
|
|
29
|
+
def export_contacts: (?notify_url: String | nil, ?list_id: id | nil, ?field_names: Array[String] | nil, ?email: String | nil, ?phone: String | nil, ?tag: String | nil, ?email_status: String | nil, ?phone_status: String | nil, ?contact_status: String | nil) -> TaskResponse
|
|
30
|
+
def get_contact_count: (list_id: id, ?params: params?, ?tag_id: id?, ?contact_type: contact_type | "address" | nil, ?search: String?) -> ContactCountResponse
|
|
31
|
+
def get_lists: () -> CollectionResponse[List]
|
|
32
|
+
def get_total_contacts_count: (login: String) -> TotalContactsResponse
|
|
33
|
+
def import_contacts: (?field_names: Array[String]?, ?data: Array[Array[parameter]]?, ?records: Enumerable[params]?, ?overwrite_tags: flag | nil, ?overwrite_lists: flag | nil, ?telegram_bot_channel_id: String | nil) -> ImportResponse
|
|
34
|
+
def subscribe: (list_ids: String | Array[id], ?fields: params?, ?email: String?, ?tags: String | Array[id] | nil, ?double_optin: Integer | :request_confirmation | :already_confirmed | :confirm_if_needed | nil, ?overwrite: Integer | :preserve | :replace | :update | nil) -> SubscriptionResponse
|
|
35
|
+
def update_list: (list_id: id, title: String, ?before_subscribe_url: String | nil, ?after_subscribe_url: String | nil, ?sub_user_rights: params | nil) -> ObjectResponse[Record]
|
|
32
36
|
def is_contact_in_lists: (email: String, list_ids: String | Array[id], condition: String) -> Response[bool]
|
|
33
|
-
def get_contact: (email: String, ?include_lists: flag | nil, ?include_fields: flag | nil, ?include_details: flag | nil) ->
|
|
34
|
-
def unsubscribe: (contact_type:
|
|
35
|
-
def cancel_campaign: (campaign_id: id) ->
|
|
36
|
-
def check_email: (email_id: String | Array[id]) ->
|
|
37
|
-
def check_sms: (sms_id: id) ->
|
|
38
|
-
def create_campaign: (message_id: id, ?start_time: String | nil, ?timezone: String | nil, ?track_read: flag | nil, ?track_links: flag | nil, ?contacts: String | Array[id] | nil, ?contacts_url: String | nil, ?track_ga: flag | nil, ?payment_limit: Integer | Float | nil, ?payment_currency: String | nil, ?ga_medium: String | nil, ?ga_source: String | nil, ?ga_campaign: String | nil, ?ga_content: String | nil, ?ga_term: String | nil) ->
|
|
39
|
-
def create_email_message: (sender_name: String
|
|
40
|
-
def create_sms_message: (sender: String, body: String, list_id: id, ?tag: String | nil) ->
|
|
41
|
-
def delete_message: (message_id: id) ->
|
|
42
|
-
def get_actual_message_version: (message_id: id) ->
|
|
43
|
-
def get_web_version: (campaign_id: id) ->
|
|
44
|
-
def send_email: (email: String, sender_name: String
|
|
45
|
-
def send_sms: (phone: String, sender: String, text: String) ->
|
|
46
|
-
def send_test_email: (email: String | Array[id], id: id) ->
|
|
47
|
-
def update_email_message: (id: id, ?sender_name: String | nil, ?sender_email: String | nil, ?subject: String | nil, ?body: String | nil, ?list_id: id | nil, ?text_body: String | nil, ?lang: String | nil, ?categories: String | Array[id] | nil) ->
|
|
48
|
-
def update_opt_in_email: (sender_name: String, sender_email: String, subject: String, body: String, list_id: id) ->
|
|
49
|
-
def get_sender_domain_list: (username: String, ?domain: String | nil, ?limit: Integer | nil, ?offset: Integer | nil) ->
|
|
50
|
-
def get_campaign_common_stats: (campaign_id: id) ->
|
|
51
|
-
def get_campaign_delivery_stats: (campaign_id: id, ?notify_url: String | nil, ?changed_since: String | nil, ?field_ids: Array[id] | nil) ->
|
|
52
|
-
def get_campaign_status: (campaign_id: id) ->
|
|
53
|
-
def get_messages: (date_from: String, date_to: String, ?limit: Integer | nil, ?offset: Integer | nil) ->
|
|
54
|
-
def get_visited_links: (campaign_id: id, ?group: flag | nil) ->
|
|
55
|
-
def list_messages: (date_from: String, date_to: String, ?limit: Integer | nil, ?offset: Integer | nil) ->
|
|
56
|
-
def get_campaigns: (from: String, ?to: String | nil, ?limit: Integer | nil, ?offset: Integer | nil) ->
|
|
57
|
-
def get_message: (id: id) ->
|
|
58
|
-
def get_task_result: (task_uuid: String) ->
|
|
59
|
-
def create_email_template: (title: String, subject: String, body: String, ?description: String | nil, ?text_body: String | nil, ?lang: String | nil) ->
|
|
60
|
-
def delete_template: (template_id: id) ->
|
|
61
|
-
def get_template: (?template_id: id | nil, ?system_template_id: id | nil) ->
|
|
62
|
-
def get_templates: (?type:
|
|
63
|
-
def list_templates: (?type:
|
|
64
|
-
def update_email_template: (template_id: id, ?title: String | nil, ?description: String | nil, ?subject: String | nil, ?body: String | nil, ?text_body: String | nil, ?lang: String | nil) ->
|
|
65
|
-
def create_field: (name: String, type: String, ?public_name: String | nil) ->
|
|
66
|
-
def delete_field: (id: id) ->
|
|
67
|
-
def delete_tag: (id: id) ->
|
|
68
|
-
def get_fields: () ->
|
|
69
|
-
def get_tags: () ->
|
|
70
|
-
def update_field: (id: id, name: String, ?public_name: String | nil) ->
|
|
71
|
-
def get_contact_field_values: (email: String, field_ids: String | Array[id]) ->
|
|
72
|
-
def create_subscriber_note: (subscriber_id: id, content: String) ->
|
|
73
|
-
def update_subscriber_note: (id: id, content: String) ->
|
|
74
|
-
def delete_subscriber_note: (id: id) ->
|
|
75
|
-
def get_subscriber_note: (id: id) ->
|
|
76
|
-
def get_subscriber_notes: (subscriber_id: id, ?limit: Integer | nil, ?offset: Integer | nil, ?order_type:
|
|
37
|
+
def get_contact: (email: String, ?include_lists: flag | nil, ?include_fields: flag | nil, ?include_details: flag | nil) -> ContactResponse
|
|
38
|
+
def unsubscribe: (?contact_type: contact_type?, ?contact: String?, ?email: String?, ?phone: String?, ?list_ids: String | Array[id] | nil) -> ObjectResponse[Record]
|
|
39
|
+
def cancel_campaign: (campaign_id: id) -> ObjectResponse[Record]
|
|
40
|
+
def check_email: (email_id: String | Array[id]) -> CollectionResponse[EmailDelivery]
|
|
41
|
+
def check_sms: (sms_id: id) -> StatusResponse
|
|
42
|
+
def create_campaign: (message_id: id, ?start_time: String | Time | nil, ?timezone: String | nil, ?track_read: flag | nil, ?track_links: flag | nil, ?contacts: String | Array[id] | nil, ?contacts_url: String | nil, ?track_ga: flag | nil, ?payment_limit: Integer | Float | nil, ?payment_currency: String | nil, ?ga_medium: String | nil, ?ga_source: String | nil, ?ga_campaign: String | nil, ?ga_content: String | nil, ?ga_term: String | nil) -> CampaignCreatedResponse
|
|
43
|
+
def create_email_message: (?sender_name: String?, ?sender_email: String?, list_id: id, ?subject: String | nil, ?body: String | nil, ?text_body: String | nil, ?generate_text: flag | nil, ?tag: String | nil, ?attachments: Hash[String, String] | Attachment | Array[Attachment] | nil, ?lang: String | nil, ?template_id: id | nil, ?system_template_id: id | nil, ?wrap_type: String | nil, ?categories: String | Array[id] | nil) -> MessageCreatedResponse
|
|
44
|
+
def create_sms_message: (sender: String, body: String, list_id: id, ?tag: String | nil) -> MessageCreatedResponse
|
|
45
|
+
def delete_message: (message_id: id) -> ObjectResponse[Record]
|
|
46
|
+
def get_actual_message_version: (message_id: id) -> MessageVersionResponse
|
|
47
|
+
def get_web_version: (campaign_id: id) -> WebVersionResponse
|
|
48
|
+
def send_email: (email: String, ?sender_name: String?, ?sender_email: String?, subject: String, body: String, list_id: id, ?attachments: Hash[String, String] | Attachment | Array[Attachment] | nil, ?lang: String | nil, ?track_read: flag | nil, ?track_links: flag | nil, ?cc: String | nil, ?headers: String | params | nil, ?images_as: String | Symbol | nil, ?ref_key: String | nil, ?error_checking: flag | nil, ?metadata: params | nil, ?reply_to: String | nil, ?priority: String | nil) -> SendResponse
|
|
49
|
+
def send_sms: (phone: String | Array[String], sender: String, text: String) -> CollectionResponse[SmsReceipt]
|
|
50
|
+
def send_test_email: (email: String | Array[id], id: id) -> MessageNoticeResponse
|
|
51
|
+
def update_email_message: (id: id, ?sender_name: String | nil, ?sender_email: String | nil, ?subject: String | nil, ?body: String | nil, ?list_id: id | nil, ?text_body: String | nil, ?lang: String | nil, ?categories: String | Array[id] | nil) -> MessageCreatedResponse
|
|
52
|
+
def update_opt_in_email: (sender_name: String, sender_email: String, subject: String, body: String, list_id: id) -> ObjectResponse[Record]
|
|
53
|
+
def get_sender_domain_list: (username: String, ?domain: String | nil, ?limit: Integer | nil, ?offset: Integer | nil) -> PageResponse[SenderDomainGroup]
|
|
54
|
+
def get_campaign_common_stats: (campaign_id: id) -> CampaignStatsResponse
|
|
55
|
+
def get_campaign_delivery_stats: (campaign_id: id, ?notify_url: String | nil, ?changed_since: String | Time | nil, ?field_ids: Array[id] | nil) -> TaskResponse
|
|
56
|
+
def get_campaign_status: (campaign_id: id) -> StatusResponse
|
|
57
|
+
def get_messages: (date_from: String | Time, date_to: String | Time, ?limit: Integer | nil, ?offset: Integer | nil) -> PageResponse[Message]
|
|
58
|
+
def get_visited_links: (campaign_id: id, ?group: flag | nil) -> CollectionResponse[Record]
|
|
59
|
+
def list_messages: (date_from: String | Time, date_to: String | Time, ?limit: Integer | nil, ?offset: Integer | nil) -> PageResponse[Message]
|
|
60
|
+
def get_campaigns: (from: String | Time, ?to: String | Time | nil, ?limit: Integer | nil, ?offset: Integer | nil) -> PageResponse[Campaign]
|
|
61
|
+
def get_message: (id: id) -> MessageResponse
|
|
62
|
+
def get_task_result: (task_uuid: String) -> TaskResponse
|
|
63
|
+
def create_email_template: (title: String, subject: String, body: String, ?description: String | nil, ?text_body: String | nil, ?lang: String | nil) -> IdentifierRecordResponse
|
|
64
|
+
def delete_template: (template_id: id) -> ObjectResponse[Record]
|
|
65
|
+
def get_template: (?template_id: id | nil, ?system_template_id: id | nil) -> TemplateResponse
|
|
66
|
+
def get_templates: (?type: template_type | nil, ?date_from: String | Time | nil, ?date_to: String | Time | nil, ?limit: Integer | nil, ?offset: Integer | nil) -> PageResponse[Template]
|
|
67
|
+
def list_templates: (?type: template_type | nil, ?date_from: String | Time | nil, ?date_to: String | Time | nil, ?limit: Integer | nil, ?offset: Integer | nil) -> PageResponse[Template]
|
|
68
|
+
def update_email_template: (template_id: id, ?title: String | nil, ?description: String | nil, ?subject: String | nil, ?body: String | nil, ?text_body: String | nil, ?lang: String | nil) -> IdentifierRecordResponse
|
|
69
|
+
def create_field: (name: String, type: String, ?public_name: String | nil) -> IdentifierRecordResponse
|
|
70
|
+
def delete_field: (id: id) -> ObjectResponse[Record]
|
|
71
|
+
def delete_tag: (id: id) -> ObjectResponse[Record]
|
|
72
|
+
def get_fields: () -> CollectionResponse[Field]
|
|
73
|
+
def get_tags: () -> CollectionResponse[Tag]
|
|
74
|
+
def update_field: (id: id, name: String, ?public_name: String | nil) -> OptionalIdentifierResponse
|
|
75
|
+
def get_contact_field_values: (email: String, field_ids: String | Array[id]) -> ContactFieldsResponse
|
|
76
|
+
def create_subscriber_note: (subscriber_id: id, content: String) -> IdentifierRecordResponse
|
|
77
|
+
def update_subscriber_note: (id: id, content: String) -> IdentifierRecordResponse
|
|
78
|
+
def delete_subscriber_note: (id: id) -> ObjectResponse[Record]
|
|
79
|
+
def get_subscriber_note: (id: id) -> NoteResponse
|
|
80
|
+
def get_subscriber_notes: (subscriber_id: id, ?limit: Integer | nil, ?offset: Integer | nil, ?order_type: note_order | nil, ?order_by: note_field | nil, ?is_pinned: flag | nil) -> PageResponse[Note]
|
|
77
81
|
end
|
|
78
82
|
end
|
data/sig/outcomes.rbs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
module Unisender
|
|
2
|
+
module Outcomes
|
|
3
|
+
def self.records: (value, String) -> Array[Record]
|
|
4
|
+
def self.record: (value, String) -> Record
|
|
5
|
+
def self.failures: (value, String, ?Hash[String, json]) -> Array[Failure]
|
|
6
|
+
def self.failure: (Record, String, Hash[String, json]) -> Failure
|
|
7
|
+
end
|
|
8
|
+
class Failure < Record
|
|
9
|
+
def index: () -> Integer?
|
|
10
|
+
def code: () -> String?
|
|
11
|
+
def message: () -> String?
|
|
12
|
+
def warning?: () -> bool
|
|
13
|
+
def with_offset: (Integer) -> Failure
|
|
14
|
+
def normalize: () -> void
|
|
15
|
+
end
|
|
16
|
+
interface _Outcome
|
|
17
|
+
def complete?: () -> bool
|
|
18
|
+
def partial?: () -> bool
|
|
19
|
+
def uncertain?: () -> bool
|
|
20
|
+
def failures: () -> Array[Failure]
|
|
21
|
+
end
|
|
22
|
+
class ImportResult < Record
|
|
23
|
+
def row_warnings: () -> Array[Failure]
|
|
24
|
+
OPTIONAL_COUNTERS: Array[String]
|
|
25
|
+
def inserted: () -> Integer?
|
|
26
|
+
def updated: () -> Integer?
|
|
27
|
+
def deleted: () -> Integer?
|
|
28
|
+
def new_emails: () -> Integer?
|
|
29
|
+
def total: () -> Integer?
|
|
30
|
+
def invalid: () -> Integer
|
|
31
|
+
def complete?: () -> bool
|
|
32
|
+
def partial?: () -> bool
|
|
33
|
+
def uncertain?: () -> bool
|
|
34
|
+
def failures: () -> Array[Failure]
|
|
35
|
+
def normalize: () -> void
|
|
36
|
+
end
|
|
37
|
+
class RecipientResult < Record
|
|
38
|
+
def id: () -> id?
|
|
39
|
+
def index: () -> Integer?
|
|
40
|
+
def email: () -> String?
|
|
41
|
+
def failures: () -> Array[Failure]
|
|
42
|
+
def accepted?: () -> bool
|
|
43
|
+
def normalize: () -> void
|
|
44
|
+
end
|
|
45
|
+
class SendResult < Record
|
|
46
|
+
def accepted_recipients: () -> Array[RecipientResult]
|
|
47
|
+
def rejected_recipients: () -> Array[RecipientResult]
|
|
48
|
+
def unknown_recipients: () -> Array[RecipientResult]
|
|
49
|
+
def accepted_ids: () -> Array[id]
|
|
50
|
+
def recipients: () -> Array[RecipientResult]
|
|
51
|
+
def email_id: () -> id?
|
|
52
|
+
def complete?: () -> bool
|
|
53
|
+
def partial?: () -> bool
|
|
54
|
+
def uncertain?: () -> bool
|
|
55
|
+
def failures: () -> Array[Failure]
|
|
56
|
+
def normalize: () -> void
|
|
57
|
+
end
|
|
58
|
+
class EventResult < Record
|
|
59
|
+
def complete?: () -> bool
|
|
60
|
+
def partial?: () -> bool
|
|
61
|
+
def uncertain?: () -> bool
|
|
62
|
+
def failures: () -> Array[Failure]
|
|
63
|
+
end
|
|
64
|
+
class OutcomeResponse[out Result < (Record & _Outcome) = ImportResult] < ObjectResponse[Result]
|
|
65
|
+
def complete?: () -> bool
|
|
66
|
+
def partial?: () -> bool
|
|
67
|
+
def uncertain?: () -> bool
|
|
68
|
+
def failures: () -> Array[Failure]
|
|
69
|
+
def raise_for_partial_failure!: () -> self
|
|
70
|
+
end
|
|
71
|
+
class ImportResponse < OutcomeResponse[ImportResult]
|
|
72
|
+
def row_warnings: () -> Array[Failure]
|
|
73
|
+
def inserted: () -> Integer?
|
|
74
|
+
def updated: () -> Integer?
|
|
75
|
+
def deleted: () -> Integer?
|
|
76
|
+
def new_emails: () -> Integer?
|
|
77
|
+
def total: () -> Integer?
|
|
78
|
+
def invalid: () -> Integer
|
|
79
|
+
end
|
|
80
|
+
class SendResponse < OutcomeResponse[SendResult]
|
|
81
|
+
def accepted_recipients: () -> Array[RecipientResult]
|
|
82
|
+
def rejected_recipients: () -> Array[RecipientResult]
|
|
83
|
+
def unknown_recipients: () -> Array[RecipientResult]
|
|
84
|
+
def accepted_ids: () -> Array[id]
|
|
85
|
+
def recipients: () -> Array[RecipientResult]
|
|
86
|
+
def email_id: () -> id?
|
|
87
|
+
end
|
|
88
|
+
class EventResponse < OutcomeResponse[EventResult]
|
|
89
|
+
end
|
|
90
|
+
end
|
data/sig/record.rbs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
module Unisender
|
|
2
|
+
class Record
|
|
3
|
+
@values: Hash[String, value]
|
|
4
|
+
def initialize: (Hash[String, json]) -> void
|
|
5
|
+
def self.decode: (json) -> value
|
|
6
|
+
def []: (String | Symbol) -> value
|
|
7
|
+
def fetch: [Fallback] (String | Symbol, *Fallback) ?{ (String | Symbol) -> Fallback } -> (value | Fallback)
|
|
8
|
+
def key?: (String | Symbol) -> bool
|
|
9
|
+
def keys: () -> Array[String]
|
|
10
|
+
def values: () -> Array[value]
|
|
11
|
+
def dig: (String | Symbol, *(String | Integer)) -> value
|
|
12
|
+
def to_h: () -> Hash[String, json]
|
|
13
|
+
alias to_hash to_h
|
|
14
|
+
def as_json: (?serialization_options?) -> Hash[String, json]
|
|
15
|
+
def to_json: (?(serialization_options | JSON::State)?) -> String
|
|
16
|
+
def self.copy: (value) -> json
|
|
17
|
+
def ==: (BasicObject) -> bool
|
|
18
|
+
def eql?: (BasicObject) -> bool
|
|
19
|
+
def hash: () -> Integer
|
|
20
|
+
def inspect: () -> String
|
|
21
|
+
def normalize: () -> void
|
|
22
|
+
def child: (singleton(EmailContact), Hash[String, json], String) -> EmailContact
|
|
23
|
+
| (singleton(PhoneContact), Hash[String, json], String) -> PhoneContact
|
|
24
|
+
| (singleton(ContactList), Hash[String, json], String) -> ContactList
|
|
25
|
+
| (singleton(SenderDomain), Hash[String, json], String) -> SenderDomain
|
|
26
|
+
| (singleton(RecipientResult), Hash[String, json], String) -> RecipientResult
|
|
27
|
+
def text: (String) -> String?
|
|
28
|
+
def text!: (String) -> String
|
|
29
|
+
def identifier!: (String) -> id
|
|
30
|
+
def integer!: (String) -> Integer
|
|
31
|
+
def integer: (String) -> Integer?
|
|
32
|
+
def number: (String) -> (Integer | Float)?
|
|
33
|
+
def invalid!: (String, ?expected_type: String) -> bot
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class CollectionResponse[out Item = Record] < Response[Array[Item]]
|
|
37
|
+
include Enumerable[Item]
|
|
38
|
+
def each: () -> Enumerator[Item, Array[Item]]
|
|
39
|
+
| () { (Item) -> void } -> Array[Item]
|
|
40
|
+
def []: (Integer) -> Item?
|
|
41
|
+
| (Range[Integer]) -> Array[Item]?
|
|
42
|
+
| (Integer, Integer) -> Array[Item]?
|
|
43
|
+
def at: (Integer) -> Item?
|
|
44
|
+
def fetch: [Fallback] (Integer, *Fallback) ?{ (Integer) -> Fallback } -> (Item | Fallback)
|
|
45
|
+
def size: () -> Integer
|
|
46
|
+
alias length size
|
|
47
|
+
def empty?: () -> bool
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class ObjectResponse[out Result < Record = Record] < Response[Result]
|
|
51
|
+
def key?: (String | Symbol) -> bool
|
|
52
|
+
def keys: () -> Array[String]
|
|
53
|
+
def values: () -> Array[value]
|
|
54
|
+
def []: (String | Symbol) -> value
|
|
55
|
+
def fetch: [Fallback] (String | Symbol, *Fallback) ?{ (String | Symbol) -> Fallback } -> (value | Fallback)
|
|
56
|
+
def to_h: () -> Hash[String, json]
|
|
57
|
+
def dig: (String | Symbol, *(String | Integer)) -> value
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
module Results
|
|
61
|
+
MODELS: Hash[String, [singleton(Record), singleton(ObjectResponse)]]
|
|
62
|
+
COLLECTION_OPERATIONS: Array[String]
|
|
63
|
+
EMPTY_OPERATIONS: Array[String]
|
|
64
|
+
def self.build: (String, Response[json]) -> Response
|
|
65
|
+
def self.boolean: (Response[json]) -> Response[json]
|
|
66
|
+
def self.validate_container: (String, json) -> void
|
|
67
|
+
def self.object: (singleton(Record), json, ?String) -> Record
|
|
68
|
+
def self.normalize: (String, json) -> json
|
|
69
|
+
def self.normalize_send: (String, json) -> json
|
|
70
|
+
def self.single_message: (json) -> json
|
|
71
|
+
def self.wrap: (json, singleton(Record), singleton(ObjectResponse), Response[json]) -> Response
|
|
72
|
+
def self.rows: (json) -> Array[Hash[String, json]]
|
|
73
|
+
def self.field_names: (Array[json]) -> Array[String]
|
|
74
|
+
def self.row_object: (Array[String], json, Integer) -> Hash[String, json]
|
|
75
|
+
def self.shape_error: (String, json, String) -> bot
|
|
76
|
+
end
|
|
77
|
+
end
|
data/sig/records.rbs
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
module Unisender
|
|
2
|
+
class IdentifierRecord < Record
|
|
3
|
+
def id: () -> id
|
|
4
|
+
def normalize: () -> void
|
|
5
|
+
end
|
|
6
|
+
class IdentifierRecordResponse < ObjectResponse[IdentifierRecord]
|
|
7
|
+
def id: () -> id
|
|
8
|
+
end
|
|
9
|
+
class List < IdentifierRecord
|
|
10
|
+
def title: () -> String
|
|
11
|
+
def normalize: () -> void
|
|
12
|
+
end
|
|
13
|
+
class ListResponse < ObjectResponse[List]
|
|
14
|
+
def id: () -> id
|
|
15
|
+
def title: () -> String
|
|
16
|
+
end
|
|
17
|
+
class Message < IdentifierRecord
|
|
18
|
+
def subject: () -> String?
|
|
19
|
+
def body: () -> String?
|
|
20
|
+
def sender_name: () -> String?
|
|
21
|
+
def sender_email: () -> String?
|
|
22
|
+
def normalize: () -> void
|
|
23
|
+
end
|
|
24
|
+
class MessageResponse < ObjectResponse[Message]
|
|
25
|
+
def id: () -> id
|
|
26
|
+
def subject: () -> String?
|
|
27
|
+
def body: () -> String?
|
|
28
|
+
def sender_name: () -> String?
|
|
29
|
+
def sender_email: () -> String?
|
|
30
|
+
end
|
|
31
|
+
class Campaign < IdentifierRecord
|
|
32
|
+
def status: () -> String?
|
|
33
|
+
def subject: () -> String?
|
|
34
|
+
def normalize: () -> void
|
|
35
|
+
end
|
|
36
|
+
class CampaignResponse < ObjectResponse[Campaign]
|
|
37
|
+
def id: () -> id
|
|
38
|
+
def status: () -> String?
|
|
39
|
+
def subject: () -> String?
|
|
40
|
+
end
|
|
41
|
+
class Template < IdentifierRecord
|
|
42
|
+
def title: () -> String?
|
|
43
|
+
def subject: () -> String?
|
|
44
|
+
def body: () -> String?
|
|
45
|
+
def normalize: () -> void
|
|
46
|
+
end
|
|
47
|
+
class TemplateResponse < ObjectResponse[Template]
|
|
48
|
+
def id: () -> id
|
|
49
|
+
def title: () -> String?
|
|
50
|
+
def subject: () -> String?
|
|
51
|
+
def body: () -> String?
|
|
52
|
+
end
|
|
53
|
+
class Field < IdentifierRecord
|
|
54
|
+
def name: () -> String
|
|
55
|
+
def type: () -> String
|
|
56
|
+
def normalize: () -> void
|
|
57
|
+
end
|
|
58
|
+
class FieldResponse < ObjectResponse[Field]
|
|
59
|
+
def id: () -> id
|
|
60
|
+
def name: () -> String
|
|
61
|
+
def type: () -> String
|
|
62
|
+
end
|
|
63
|
+
class Tag < IdentifierRecord
|
|
64
|
+
def name: () -> String
|
|
65
|
+
def normalize: () -> void
|
|
66
|
+
end
|
|
67
|
+
class TagResponse < ObjectResponse[Tag]
|
|
68
|
+
def id: () -> id
|
|
69
|
+
def name: () -> String
|
|
70
|
+
end
|
|
71
|
+
class Note < IdentifierRecord
|
|
72
|
+
def user_id: () -> id?
|
|
73
|
+
def subscriber_id: () -> id?
|
|
74
|
+
def origin: () -> String?
|
|
75
|
+
def is_pinned: () -> bool?
|
|
76
|
+
def created_at: () -> String?
|
|
77
|
+
def updated_at: () -> String?
|
|
78
|
+
def pinned_at: () -> String?
|
|
79
|
+
def content: () -> String
|
|
80
|
+
def normalize: () -> void
|
|
81
|
+
end
|
|
82
|
+
class NoteResponse < ObjectResponse[Note]
|
|
83
|
+
def user_id: () -> id?
|
|
84
|
+
def subscriber_id: () -> id?
|
|
85
|
+
def origin: () -> String?
|
|
86
|
+
def is_pinned: () -> bool?
|
|
87
|
+
def created_at: () -> String?
|
|
88
|
+
def updated_at: () -> String?
|
|
89
|
+
def pinned_at: () -> String?
|
|
90
|
+
def id: () -> id
|
|
91
|
+
def content: () -> String
|
|
92
|
+
end
|
|
93
|
+
class MessageCreated < Record
|
|
94
|
+
def message_id: () -> id
|
|
95
|
+
def normalize: () -> void
|
|
96
|
+
end
|
|
97
|
+
class MessageCreatedResponse < ObjectResponse[MessageCreated]
|
|
98
|
+
def message_id: () -> id
|
|
99
|
+
end
|
|
100
|
+
class Subscription < Record
|
|
101
|
+
def person_id: () -> id
|
|
102
|
+
def normalize: () -> void
|
|
103
|
+
end
|
|
104
|
+
class SubscriptionResponse < ObjectResponse[Subscription]
|
|
105
|
+
def person_id: () -> id
|
|
106
|
+
end
|
|
107
|
+
class CampaignCreated < Record
|
|
108
|
+
def count: () -> Integer?
|
|
109
|
+
def campaign_id: () -> id
|
|
110
|
+
def status: () -> String
|
|
111
|
+
def normalize: () -> void
|
|
112
|
+
end
|
|
113
|
+
class CampaignCreatedResponse < ObjectResponse[CampaignCreated]
|
|
114
|
+
def count: () -> Integer?
|
|
115
|
+
def campaign_id: () -> id
|
|
116
|
+
def status: () -> String
|
|
117
|
+
end
|
|
118
|
+
class Status < Record
|
|
119
|
+
def status: () -> String
|
|
120
|
+
def normalize: () -> void
|
|
121
|
+
end
|
|
122
|
+
class StatusResponse < ObjectResponse[Status]
|
|
123
|
+
def status: () -> String
|
|
124
|
+
end
|
|
125
|
+
class ContactCount < Record
|
|
126
|
+
def count: () -> Integer
|
|
127
|
+
def normalize: () -> void
|
|
128
|
+
end
|
|
129
|
+
class ContactCountResponse < ObjectResponse[ContactCount]
|
|
130
|
+
def count: () -> Integer
|
|
131
|
+
end
|
|
132
|
+
class TotalContacts < Record
|
|
133
|
+
def total: () -> Integer
|
|
134
|
+
def normalize: () -> void
|
|
135
|
+
end
|
|
136
|
+
class TotalContactsResponse < ObjectResponse[TotalContacts]
|
|
137
|
+
def total: () -> Integer
|
|
138
|
+
end
|
|
139
|
+
class MessageVersion < Record
|
|
140
|
+
def message_id: () -> id
|
|
141
|
+
def actual_version_id: () -> id
|
|
142
|
+
def normalize: () -> void
|
|
143
|
+
end
|
|
144
|
+
class MessageVersionResponse < ObjectResponse[MessageVersion]
|
|
145
|
+
def message_id: () -> id
|
|
146
|
+
def actual_version_id: () -> id
|
|
147
|
+
end
|
|
148
|
+
class WebVersion < Record
|
|
149
|
+
def letter_id: () -> id
|
|
150
|
+
def web_letter_link: () -> String
|
|
151
|
+
def normalize: () -> void
|
|
152
|
+
end
|
|
153
|
+
class WebVersionResponse < ObjectResponse[WebVersion]
|
|
154
|
+
def letter_id: () -> id
|
|
155
|
+
def web_letter_link: () -> String
|
|
156
|
+
end
|
|
157
|
+
class TaskResult < Record
|
|
158
|
+
def task_uuid: () -> String?
|
|
159
|
+
def status: () -> String
|
|
160
|
+
def file_to_download: () -> String?
|
|
161
|
+
def normalize: () -> void
|
|
162
|
+
end
|
|
163
|
+
class TaskResultResponse < ObjectResponse[TaskResult]
|
|
164
|
+
def task_uuid: () -> String?
|
|
165
|
+
def status: () -> String
|
|
166
|
+
def file_to_download: () -> String?
|
|
167
|
+
end
|
|
168
|
+
class OptionalIdentifier < Record
|
|
169
|
+
def id: () -> id?
|
|
170
|
+
def normalize: () -> void
|
|
171
|
+
end
|
|
172
|
+
class OptionalIdentifierResponse < ObjectResponse[OptionalIdentifier]
|
|
173
|
+
def id: () -> id?
|
|
174
|
+
end
|
|
175
|
+
class MessageNotice < Record
|
|
176
|
+
def message: () -> String?
|
|
177
|
+
def normalize: () -> void
|
|
178
|
+
end
|
|
179
|
+
class MessageNoticeResponse < ObjectResponse[MessageNotice]
|
|
180
|
+
def message: () -> String?
|
|
181
|
+
end
|
|
182
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Unisender
|
|
2
|
+
type serialization_fields = String | Symbol | Array[String | Symbol]
|
|
3
|
+
type serialization_options = Hash[String | Symbol, serialization_fields]
|
|
4
|
+
module Serialization
|
|
5
|
+
OPTIONS: Array[String]
|
|
6
|
+
def self.payload: (Record, ?serialization_options?) -> Hash[String, json]
|
|
7
|
+
| (value, ?serialization_options?) -> json
|
|
8
|
+
def self.json: (value, ?(serialization_options | JSON::State)?) -> String
|
|
9
|
+
def self.options_for: (serialization_options?) -> Hash[Symbol, Array[String]]
|
|
10
|
+
def self.field_names: (serialization_fields) -> Array[String]
|
|
11
|
+
def self.filter: (json, Hash[Symbol, Array[String]]) -> json
|
|
12
|
+
end
|
|
13
|
+
end
|
data/sig/tasks.rbs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Unisender
|
|
2
|
+
interface _Downloader
|
|
3
|
+
def download: (String, _Writable, max_bytes: Integer) -> DownloadReceipt
|
|
4
|
+
end
|
|
5
|
+
class TaskResponse < TaskResultResponse
|
|
6
|
+
def completed?: () -> bool
|
|
7
|
+
def failed?: () -> bool
|
|
8
|
+
def pending?: () -> bool
|
|
9
|
+
@client: Client
|
|
10
|
+
attr_reader task_uuid: String
|
|
11
|
+
def initialize: (TaskResultResponse, client: Client, task_uuid: String) -> void
|
|
12
|
+
def wait: (?interval: duration, ?timeout: duration, ?clock: ( ^() -> Float)?, ?sleeper: ( ^(duration) -> void)?) ?{ (TaskResponse) -> void } -> TaskResponse
|
|
13
|
+
def download_to: (_Writable, max_bytes: Integer, ?downloader: _Downloader) -> DownloadReceipt
|
|
14
|
+
private
|
|
15
|
+
def download_file: (String, _Writable, Integer, _Downloader) -> DownloadReceipt
|
|
16
|
+
end
|
|
17
|
+
class TaskFailedError < TaskError
|
|
18
|
+
end
|
|
19
|
+
class UnknownTaskStateError < TaskError
|
|
20
|
+
end
|
|
21
|
+
class TaskTimeoutError < TimeoutError
|
|
22
|
+
attr_reader response: TaskResponse
|
|
23
|
+
attr_reader task_uuid: String
|
|
24
|
+
def initialize: (TaskResponse) -> void
|
|
25
|
+
end
|
|
26
|
+
end
|
data/sig/testing.rbs
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module Unisender
|
|
2
|
+
module Testing
|
|
3
|
+
class Request < Data
|
|
4
|
+
attr_reader uri: URI::Generic
|
|
5
|
+
attr_reader headers: Hash[String, String]
|
|
6
|
+
attr_reader body: String
|
|
7
|
+
def self.new: (uri: URI::Generic, headers: Hash[String, String], body: String) -> Request
|
|
8
|
+
alias to_s inspect
|
|
9
|
+
def operation: () -> String
|
|
10
|
+
def form: () -> Hash[String, String]
|
|
11
|
+
def json: () -> json
|
|
12
|
+
def inspect: () -> String
|
|
13
|
+
end
|
|
14
|
+
class Reply < Data
|
|
15
|
+
attr_reader operation: String?
|
|
16
|
+
attr_reader response: HTTPResponse | StandardError
|
|
17
|
+
attr_reader expected_form: Hash[String, String]?
|
|
18
|
+
attr_reader expected_json: json?
|
|
19
|
+
def self.new: (operation: String?, response: HTTPResponse | StandardError, expected_form: Hash[String, String]?, expected_json: json?) -> Reply
|
|
20
|
+
end
|
|
21
|
+
class Transport
|
|
22
|
+
@replies: Array[Reply]
|
|
23
|
+
@requests: Array[Request]
|
|
24
|
+
def initialize: () -> void
|
|
25
|
+
def enqueue: (data: Hash[String, json], ?http_status: Integer, ?headers: Hash[String, String], ?operation: String?, ?expected_form: Hash[String, String]?, ?expected_json: json?) -> self
|
|
26
|
+
def enqueue_response: (HTTPResponse | StandardError, ?operation: String?, ?expected_form: Hash[String, String]?, ?expected_json: json?) -> self
|
|
27
|
+
def requests: () -> Array[Request]
|
|
28
|
+
def verify!: () -> self
|
|
29
|
+
def post: (URI::Generic, headers: Hash[String, String], body: String) -> HTTPResponse
|
|
30
|
+
def inspect: () -> String
|
|
31
|
+
private
|
|
32
|
+
def next_response: (Request) -> (HTTPResponse | StandardError)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
module Unisender
|
|
38
|
+
module Testing
|
|
39
|
+
module Fixtures
|
|
40
|
+
def self.list: (id: id, title: String) -> Hash[String, json]
|
|
41
|
+
def self.import_result: (total: Integer, ?invalid: Integer, ?log: Array[Hash[String, json]]) -> Hash[String, json]
|
|
42
|
+
def self.task: (status: String, task_uuid: String, ?file_to_download: String?) -> Hash[String, json]
|
|
43
|
+
def self.recipient: (index: Integer, email: String, ?id: id?, ?errors: Array[Hash[String, json]]) -> Hash[String, json]
|
|
44
|
+
end
|
|
45
|
+
module Assertions
|
|
46
|
+
def self.check: (Request, Hash[String, String]?, json?) -> void
|
|
47
|
+
def self.validate: (Hash[String, String]?, json?) -> void
|
|
48
|
+
def self.subset!: (json, json, String) -> void
|
|
49
|
+
def self.hash!: (json, Hash[String, json], String) -> void
|
|
50
|
+
def self.array!: (json, Array[json], String) -> void
|
|
51
|
+
def self.mismatch!: (String) -> bot
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|