stannp 0.4.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/stannp/client.rb +12 -0
- data/lib/stannp/objects/batch.rb +5 -0
- data/lib/stannp/objects/campaign.rb +5 -0
- data/lib/stannp/objects/campaign_cost.rb +5 -0
- data/lib/stannp/objects/group.rb +5 -0
- data/lib/stannp/objects/letter.rb +5 -0
- data/lib/stannp/resource.rb +8 -2
- data/lib/stannp/resources/campaigns.rb +50 -0
- data/lib/stannp/resources/groups.rb +38 -0
- data/lib/stannp/resources/letters.rb +30 -0
- data/lib/stannp/version.rb +1 -1
- data/lib/stannp.rb +8 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e29851d6d5a2f08247c7840729b21d9da1db101165deae90e43560fabd6db13
|
4
|
+
data.tar.gz: 258c841164c6abd4312f156252b9087e6fdc75f55708d874dd99e82d7cf223f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0800d2c215fb73f6f5d559a5e1bd1ff4cc8025cdedd61d452088adc4efa5288c7221a7a35733d5a1a046e9fd96f1cf4f8527d793676560bbca6bedd1602f386b'
|
7
|
+
data.tar.gz: 0b92c7ad6ae8f5d6dba704d85c6827e4f9aadd6e10ca9d5a4f5426e963465becc637f411bb2567b790e304d9b7d86f5a3180371c40c17c7b4c2e36f1c8e85618
|
data/CHANGELOG.md
CHANGED
@@ -11,3 +11,12 @@
|
|
11
11
|
|
12
12
|
## [0.4.0] - 2022-04-16
|
13
13
|
- Add support for the Postcards API
|
14
|
+
|
15
|
+
## [0.5.0] - 2022-04-16
|
16
|
+
- Add support for the Letters API
|
17
|
+
|
18
|
+
## [0.6.0] - 2022-04-21
|
19
|
+
- Add support for the Groups API
|
20
|
+
|
21
|
+
## [0.7.0] - 2022-04-22
|
22
|
+
- Add support for the Campaigns API
|
data/lib/stannp/client.rb
CHANGED
@@ -34,6 +34,18 @@ module Stannp
|
|
34
34
|
PostcardsResource.new(client: self)
|
35
35
|
end
|
36
36
|
|
37
|
+
def letters
|
38
|
+
LettersResource.new(client: self)
|
39
|
+
end
|
40
|
+
|
41
|
+
def groups
|
42
|
+
GroupsResource.new(client: self)
|
43
|
+
end
|
44
|
+
|
45
|
+
def campaigns
|
46
|
+
CampaignsResource.new(client: self)
|
47
|
+
end
|
48
|
+
|
37
49
|
def connection
|
38
50
|
@connection ||= Faraday.new do |conn|
|
39
51
|
conn.url_prefix = BASE_URL
|
data/lib/stannp/resource.rb
CHANGED
@@ -14,8 +14,14 @@ module Stannp
|
|
14
14
|
handle_response client.connection.post(url, body, headers)
|
15
15
|
end
|
16
16
|
|
17
|
-
def url_for(path:)
|
18
|
-
"#{path}?api_key=#{client.api_key}"
|
17
|
+
def url_for(path:, params: nil)
|
18
|
+
url = "#{path}?api_key=#{client.api_key}"
|
19
|
+
params&.each do |k, v|
|
20
|
+
next unless v
|
21
|
+
|
22
|
+
url += "&#{k}=#{v}"
|
23
|
+
end
|
24
|
+
url
|
19
25
|
end
|
20
26
|
|
21
27
|
private
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stannp
|
4
|
+
class CampaignsResource < Resource
|
5
|
+
def list
|
6
|
+
url = url_for(path: 'campaigns/list')
|
7
|
+
List.from_request(data: get_request(url).body['data'], type: Campaign)
|
8
|
+
end
|
9
|
+
|
10
|
+
def get(id:)
|
11
|
+
url = url_for(path: "campaigns/get/#{id}")
|
12
|
+
Campaign.new(get_request(url).body['data'])
|
13
|
+
end
|
14
|
+
|
15
|
+
def cost(id:)
|
16
|
+
url = url_for(path: 'campaigns/cost')
|
17
|
+
CampaignCost.new(post_request(url, body: { id: id }).body['data'])
|
18
|
+
end
|
19
|
+
|
20
|
+
def available_booking_dates(start_date: nil, end_date: nil)
|
21
|
+
url = url_for(path: 'campaigns/availableDates')
|
22
|
+
post_request(url, body: { start: start_date, end: end_date }).body['data']
|
23
|
+
end
|
24
|
+
|
25
|
+
def create(attributes:)
|
26
|
+
url = url_for(path: 'campaigns/create')
|
27
|
+
Campaign.new(id: post_request(url, body: attributes).body['data'])
|
28
|
+
end
|
29
|
+
|
30
|
+
def sample_url(id:)
|
31
|
+
url = url_for(path: 'campaigns/sample')
|
32
|
+
post_request(url, body: { id: id }).body['data']
|
33
|
+
end
|
34
|
+
|
35
|
+
def approve(id:)
|
36
|
+
url = url_for(path: 'campaigns/approve')
|
37
|
+
post_request(url, body: { id: id }).body['success']
|
38
|
+
end
|
39
|
+
|
40
|
+
def delete(id:)
|
41
|
+
url = url_for(path: 'campaigns/delete')
|
42
|
+
post_request(url, body: { id: id }).body['success']
|
43
|
+
end
|
44
|
+
|
45
|
+
def book(id:, **options)
|
46
|
+
url = url_for(path: 'campaigns/book')
|
47
|
+
post_request(url, body: { id: id }.merge(options)).body['success']
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stannp
|
4
|
+
class GroupsResource < Resource
|
5
|
+
def list(offset: nil, limit: nil)
|
6
|
+
params = { offset: offset, limit: limit }
|
7
|
+
url = url_for(path: 'groups/list', params: params)
|
8
|
+
List.from_request(data: get_request(url).body['data'], type: Group)
|
9
|
+
end
|
10
|
+
|
11
|
+
def create(name:)
|
12
|
+
url = url_for(path: 'groups/new')
|
13
|
+
Group.new(post_request(url, body: { name: name }).body['data'])
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_recipients(id:, recipient_ids:)
|
17
|
+
url = url_for(path: "groups/add/#{id}")
|
18
|
+
ids = recipient_ids.is_a?(Array) ? recipient_ids.join(',') : recipient_ids
|
19
|
+
post_request(url, body: { recipients: ids }).body['success']
|
20
|
+
end
|
21
|
+
|
22
|
+
def remove_recipients(id:, recipient_ids:)
|
23
|
+
url = url_for(path: "groups/remove/#{id}")
|
24
|
+
ids = recipient_ids.is_a?(Array) ? recipient_ids.join(',') : recipient_ids
|
25
|
+
post_request(url, body: { recipients: ids }).body['success']
|
26
|
+
end
|
27
|
+
|
28
|
+
def delete(id:)
|
29
|
+
url = url_for(path: "groups/delete/#{id}")
|
30
|
+
post_request(url, body: { id: id }).body['success']
|
31
|
+
end
|
32
|
+
|
33
|
+
def purge(id:, delete_recipients: false)
|
34
|
+
url = url_for(path: "groups/purge/#{id}")
|
35
|
+
post_request(url, body: { id: id, delete_recipients: delete_recipients }).body['success']
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stannp
|
4
|
+
class LettersResource < Resource
|
5
|
+
def create(attributes:)
|
6
|
+
url = url_for(path: 'letters/create')
|
7
|
+
Letter.new(post_request(url, body: attributes).body['data'])
|
8
|
+
end
|
9
|
+
|
10
|
+
def post(attributes:)
|
11
|
+
url = url_for(path: 'letters/post')
|
12
|
+
Letter.new(post_request(url, body: attributes).body['data'])
|
13
|
+
end
|
14
|
+
|
15
|
+
def get(id:)
|
16
|
+
url = url_for(path: "letters/get/#{id}")
|
17
|
+
Letter.new(get_request(url).body['data'])
|
18
|
+
end
|
19
|
+
|
20
|
+
def cancel(id:)
|
21
|
+
url = url_for(path: 'letters/cancel')
|
22
|
+
post_request(url, body: { id: id }).body['success']
|
23
|
+
end
|
24
|
+
|
25
|
+
def batch(attributes:)
|
26
|
+
url = url_for(path: 'letters/batch')
|
27
|
+
Batch.new(post_request(url, body: attributes).body['data'])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/stannp/version.rb
CHANGED
data/lib/stannp.rb
CHANGED
@@ -14,9 +14,17 @@ module Stannp
|
|
14
14
|
autoload :RecipientsResource, 'stannp/resources/recipients'
|
15
15
|
autoload :AddressesResource, 'stannp/resources/addresses'
|
16
16
|
autoload :PostcardsResource, 'stannp/resources/postcards'
|
17
|
+
autoload :LettersResource, 'stannp/resources/letters'
|
18
|
+
autoload :GroupsResource, 'stannp/resources/groups'
|
19
|
+
autoload :CampaignsResource, 'stannp/resources/campaigns'
|
17
20
|
# objects
|
18
21
|
autoload :User, 'stannp/objects/user'
|
19
22
|
autoload :Recipient, 'stannp/objects/recipient'
|
20
23
|
autoload :Receipt, 'stannp/objects/receipt'
|
21
24
|
autoload :Postcard, 'stannp/objects/postcard'
|
25
|
+
autoload :Letter, 'stannp/objects/letter'
|
26
|
+
autoload :Batch, 'stannp/objects/batch'
|
27
|
+
autoload :Group, 'stannp/objects/group'
|
28
|
+
autoload :Campaign, 'stannp/objects/campaign'
|
29
|
+
autoload :CampaignCost, 'stannp/objects/campaign_cost'
|
22
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stannp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k-p-jones
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -58,6 +58,11 @@ files:
|
|
58
58
|
- lib/stannp/error.rb
|
59
59
|
- lib/stannp/list.rb
|
60
60
|
- lib/stannp/object.rb
|
61
|
+
- lib/stannp/objects/batch.rb
|
62
|
+
- lib/stannp/objects/campaign.rb
|
63
|
+
- lib/stannp/objects/campaign_cost.rb
|
64
|
+
- lib/stannp/objects/group.rb
|
65
|
+
- lib/stannp/objects/letter.rb
|
61
66
|
- lib/stannp/objects/postcard.rb
|
62
67
|
- lib/stannp/objects/receipt.rb
|
63
68
|
- lib/stannp/objects/recipient.rb
|
@@ -65,6 +70,9 @@ files:
|
|
65
70
|
- lib/stannp/resource.rb
|
66
71
|
- lib/stannp/resources/account.rb
|
67
72
|
- lib/stannp/resources/addresses.rb
|
73
|
+
- lib/stannp/resources/campaigns.rb
|
74
|
+
- lib/stannp/resources/groups.rb
|
75
|
+
- lib/stannp/resources/letters.rb
|
68
76
|
- lib/stannp/resources/postcards.rb
|
69
77
|
- lib/stannp/resources/recipients.rb
|
70
78
|
- lib/stannp/resources/user.rb
|