unione-ruby 0.0.2 → 1.0.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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +90 -9
  3. data/Rakefile +49 -0
  4. data/config/response_schema/domain.yml +74 -0
  5. data/config/response_schema/email.yml +23 -0
  6. data/config/response_schema/event_dump.yml +75 -0
  7. data/config/response_schema/project.yml +59 -0
  8. data/config/response_schema/suppression.yml +71 -0
  9. data/config/response_schema/system.yml +33 -0
  10. data/config/response_schema/tag.yml +26 -0
  11. data/config/response_schema/template.yml +134 -0
  12. data/config/response_schema/unsubscribed.yml +45 -0
  13. data/config/response_schema/webhook.yml +141 -0
  14. data/examples/api/custom_api.rb +14 -0
  15. data/examples/api/domain.rb +14 -7
  16. data/examples/api/email/attachments.rb +28 -0
  17. data/examples/api/email/multiple_recipients.rb +24 -0
  18. data/examples/api/email/send.rb +25 -0
  19. data/examples/api/email/settings.rb +41 -0
  20. data/examples/api/email/subscribe.rb +14 -0
  21. data/examples/api/email/template.rb +26 -0
  22. data/examples/api/event_dump.rb +44 -0
  23. data/examples/api/project.rb +30 -23
  24. data/examples/api/suppression.rb +34 -0
  25. data/examples/api/system.rb +6 -6
  26. data/examples/api/tag.rb +15 -0
  27. data/examples/api/template.rb +40 -28
  28. data/examples/api/unsubscribed.rb +17 -11
  29. data/examples/api/webhook.rb +28 -25
  30. data/examples/helpers.rb +29 -0
  31. data/examples/send_mail.rb +44 -0
  32. data/examples/setup.rb +21 -14
  33. data/lib/unione/client/domain.rb +21 -45
  34. data/lib/unione/client/email.rb +16 -15
  35. data/lib/unione/client/event_dump.rb +37 -0
  36. data/lib/unione/client/project.rb +19 -61
  37. data/lib/unione/client/suppression.rb +38 -0
  38. data/lib/unione/client/system.rb +12 -17
  39. data/lib/unione/client/tag.rb +24 -0
  40. data/lib/unione/client/template.rb +19 -66
  41. data/lib/unione/client/unsubscribed.rb +18 -31
  42. data/lib/unione/client/webhook.rb +19 -65
  43. data/lib/unione/client.rb +33 -11
  44. data/lib/unione/connection.rb +7 -3
  45. data/lib/unione/helpers.rb +22 -0
  46. data/lib/unione/response/raise_error.rb +4 -5
  47. data/lib/unione/validation.rb +34 -9
  48. data/lib/unione/version.rb +1 -1
  49. data/lib/unione-ruby.rb +0 -3
  50. data/test/CONFIGFILE.yml +71 -0
  51. data/unione-ruby.gemspec +2 -2
  52. metadata +32 -10
  53. data/examples/api/email.rb +0 -51
  54. data/examples/sending_mail.rb +0 -32
  55. data/lib/unione/helpers/mail/mail.rb +0 -42
  56. data/lib/unione/helpers/template/template.rb +0 -32
  57. data/lib/unione/helpers/webhook/webhook.rb +0 -18
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unione-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - UniOne developer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-16 00:00:00.000000000 Z
11
+ date: 2023-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
61
+ version: '4.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
68
+ version: '4.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: hashie
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -103,31 +103,53 @@ files:
103
103
  - LICENSE
104
104
  - README.md
105
105
  - Rakefile
106
+ - config/response_schema/domain.yml
107
+ - config/response_schema/email.yml
108
+ - config/response_schema/event_dump.yml
109
+ - config/response_schema/project.yml
110
+ - config/response_schema/suppression.yml
111
+ - config/response_schema/system.yml
112
+ - config/response_schema/tag.yml
113
+ - config/response_schema/template.yml
114
+ - config/response_schema/unsubscribed.yml
115
+ - config/response_schema/webhook.yml
116
+ - examples/api/custom_api.rb
106
117
  - examples/api/domain.rb
107
- - examples/api/email.rb
118
+ - examples/api/email/attachments.rb
119
+ - examples/api/email/multiple_recipients.rb
120
+ - examples/api/email/send.rb
121
+ - examples/api/email/settings.rb
122
+ - examples/api/email/subscribe.rb
123
+ - examples/api/email/template.rb
124
+ - examples/api/event_dump.rb
108
125
  - examples/api/project.rb
126
+ - examples/api/suppression.rb
109
127
  - examples/api/system.rb
128
+ - examples/api/tag.rb
110
129
  - examples/api/template.rb
111
130
  - examples/api/unsubscribed.rb
112
131
  - examples/api/webhook.rb
113
- - examples/sending_mail.rb
132
+ - examples/helpers.rb
133
+ - examples/send_mail.rb
114
134
  - examples/setup.rb
115
135
  - lib/unione-ruby.rb
116
136
  - lib/unione/client.rb
117
137
  - lib/unione/client/domain.rb
118
138
  - lib/unione/client/email.rb
139
+ - lib/unione/client/event_dump.rb
119
140
  - lib/unione/client/project.rb
141
+ - lib/unione/client/suppression.rb
120
142
  - lib/unione/client/system.rb
143
+ - lib/unione/client/tag.rb
121
144
  - lib/unione/client/template.rb
122
145
  - lib/unione/client/unsubscribed.rb
123
146
  - lib/unione/client/webhook.rb
124
147
  - lib/unione/connection.rb
125
- - lib/unione/helpers/mail/mail.rb
126
- - lib/unione/helpers/template/template.rb
127
- - lib/unione/helpers/webhook/webhook.rb
148
+ - lib/unione/helpers.rb
128
149
  - lib/unione/response/raise_error.rb
129
150
  - lib/unione/validation.rb
130
151
  - lib/unione/version.rb
152
+ - test/CONFIGFILE.yml
131
153
  - unione-ruby.gemspec
132
154
  homepage: https://github.com/unione-repo/unione-ruby
133
155
  licenses:
@@ -141,7 +163,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
163
  requirements:
142
164
  - - ">="
143
165
  - !ruby/object:Gem::Version
144
- version: '2.4'
166
+ version: '2.5'
145
167
  required_rubygems_version: !ruby/object:Gem::Requirement
146
168
  requirements:
147
169
  - - ">="
@@ -1,51 +0,0 @@
1
- require 'unione-ruby'
2
- require 'json'
3
-
4
- unione = UniOne::Client.new(data_center: 'eu1', lang: 'en', api_key: ENV['UNIONE_API_KEY'])
5
-
6
- # sending mail
7
- mail = UniOne::Mail.new
8
-
9
- mail.subject = 'Email Subject'
10
- mail.from = { from_email: 'test@qadns.net', from_name: 'userName' }
11
-
12
- # Using body
13
- mail.body = { html: '<b>Hello {{substitutionName}}</b>' }
14
-
15
- # Using template
16
- # mail.template = { template_engine: 'simple', template_id: 'template_id' }
17
-
18
- substitutions = { 'substitutionName' => 'substitutionVal', to_name: 'Name Surname 1' }
19
- recipient1 = { email: 'test1@example.com', substitutions: substitutions, metadata: { key1: 'val1' } }
20
- mail.recipients << recipient1
21
-
22
- substitutions = { 'substitutionName' => 'substitutionVal', to_name: 'Name Surname 2' }
23
- recipient2 = { email: 'test2@example.com', substitutions: substitutions, metadata: { key1: 'val1' } }
24
- mail.recipients << recipient2
25
-
26
- mail.global_metadata = { key1: 'val1' }
27
- mail.headers = { 'X-ReplyTo' => 'reply@qadns.net' }
28
- mail.track = { track_links: 1, track_read: 1 }
29
- mail.options = { unsubscribe_url: 'someurl' }
30
-
31
- # Should have rights to use this option
32
- # mail.skip_unsubscribe = 1
33
- mail.force_send = 0
34
-
35
- mail.attachments << { type: 'text/plain', name: 'myfile.txt', content: 'ZXhhbXBsZSBmaWxl' }
36
- mail.inline_attachments << { type: 'image/png', name: 'IMAGECID', content: 'iVBORw0KGgo' }
37
-
38
- puts mail.to_json
39
-
40
- response = unione.send_email(mail.to_json)
41
-
42
- puts response.status
43
- puts response.body
44
- puts response.headers
45
-
46
- # subscribe email
47
- response = unione.subscribe_email(
48
- from_email: 'from@qadns.net',
49
- from_name: 'Example Sender',
50
- to_email: 'blackhole@example.com'
51
- )
@@ -1,32 +0,0 @@
1
- require 'unione-ruby'
2
- require 'json'
3
-
4
- unione = UniOne::Client.new(data_center: 'eu1', lang: 'en', api_key: ENV['UNIONE_API_KEY'])
5
-
6
- mail = UniOne::Mail.new
7
-
8
- template_id = "bc0372d4-69f2-11eb-9d14-366b3a36c9e1"
9
- mail.template = { template_engine: 'simple', template_id: template_id }
10
-
11
- mail.from = { from_email: 'test@qadns.net', from_name: 'userName' }
12
-
13
- substitutions = { 'substitutionName' => 'substitutionVal', to_name: 'Name Surname 1' }
14
- recipient = { email: 'test1@example.com', substitutions: substitutions, metadata: { key1: 'val1' } }
15
- mail.recipients << recipient
16
-
17
- substitutions = { 'substitutionName' => 'substitutionVal', to_name: 'Name Surname 2' }
18
- recipient = { email: 'test2@example.com', substitutions: substitutions, metadata: { key1: 'val1' } }
19
- mail.recipients << recipient
20
-
21
- mail.global_metadata = { key1: 'val1' }
22
- mail.headers = { 'X-ReplyTo' => 'reply@example.com' }
23
- mail.options = { unsubscribe_url: 'someurl' }
24
-
25
- mail.attachments << { type: 'text/plain', name: 'myfile.txt', content: 'ZXhhbXBsZSBmaWxl' }
26
- mail.inline_attachments << { type: 'image/png', name: 'IMAGECID', content: 'iVBORw0KGgo' }
27
-
28
- response = unione.send_email(mail.to_json)
29
-
30
- puts response.status
31
- puts response.body.to_h
32
- puts response.headers
@@ -1,42 +0,0 @@
1
- module UniOne
2
- class Mail
3
- attr_accessor :template, :body, :track, :from, :subject, :global_metadata, :headers, :options,
4
- :global_substitutions, :recipients, :attachments, :inline_attachments,
5
- :reply_to, :skip_unsubscribe, :force_send
6
-
7
- def initialize
8
- @template = {}
9
- @from = {}
10
- @track = {}
11
- @global_substitutions = {}
12
- @recipients = []
13
- @attachments = []
14
- @inline_attachments = []
15
- end
16
-
17
- # backward compatibility
18
- alias_method :"metadata=", :"global_metadata="
19
-
20
- def to_json(*)
21
- {
22
- message: {
23
- global_substitutions: self.global_substitutions,
24
- body: self.body,
25
- subject: self.subject,
26
- reply_to: self.reply_to,
27
- recipients: self.recipients,
28
- global_metadata: self.global_metadata,
29
- headers: self.headers,
30
- attachments: self.attachments,
31
- inline_attachments: self.inline_attachments,
32
- options: self.options,
33
- skip_unsubscribe: self.skip_unsubscribe,
34
- force_send: self.force_send
35
- }.merge(self.template)
36
- .merge(self.from)
37
- .merge(self.track)
38
- .delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {}}
39
- }
40
- end
41
- end
42
- end
@@ -1,32 +0,0 @@
1
- module UniOne
2
- class Template
3
- attr_accessor :name, :editor_type, :subject, :template_engine, :global_substitutions, :from,
4
- :headers, :body, :attachments, :inline_attachments, :options
5
-
6
- def initialize
7
- @global_substitutions = {}
8
- @from = {}
9
- @attachments = []
10
- @inline_attachments = []
11
- end
12
-
13
- def to_json(*)
14
- {
15
- template: {
16
- id: '',
17
- name: self.name,
18
- editor_type: self.editor_type,
19
- subject: self.subject,
20
- template_engine: self.template_engine,
21
- global_substitutions: self.global_substitutions,
22
- headers: self.headers,
23
- body: self.body,
24
- attachments: self.attachments,
25
- inline_attachments: self.inline_attachments,
26
- options: self.options
27
- }.merge(self.from)
28
- .delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {}}
29
- }
30
- end
31
- end
32
- end
@@ -1,18 +0,0 @@
1
- module UniOne
2
- class Webhook
3
- attr_accessor :url, :status, :settings, :events
4
-
5
- def initialize
6
- @settings = {}
7
- end
8
-
9
- def to_json(*)
10
- {
11
- url: self.url,
12
- status: self.status,
13
- events: self.events
14
- }.merge(self.settings)
15
- .delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {}}
16
- end
17
- end
18
- end