stannp 0.5.0 → 0.8.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/campaign.rb +5 -0
- data/lib/stannp/objects/campaign_cost.rb +5 -0
- data/lib/stannp/objects/group.rb +5 -0
- data/lib/stannp/resource.rb +8 -2
- data/lib/stannp/resources/campaigns.rb +50 -0
- data/lib/stannp/resources/events.rb +10 -0
- data/lib/stannp/resources/groups.rb +38 -0
- data/lib/stannp/version.rb +1 -1
- data/lib/stannp.rb +6 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4fc37e08318f2d85aefc3cdcfedc1ce1a1f4656bfff9f40948113a8d99bd3f1
|
4
|
+
data.tar.gz: f219b6b64f689aac0861cfd752f886a0939db07953d3f1d0bdd3ed7a693222d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d98546cd10f13d495414db820f987a018a020ff6027441785e4ae36a47e6e47354dbbf41c8cc0e869c38f52fea4763d0359adb4c482b5273187444fb8530d7a1
|
7
|
+
data.tar.gz: 50fa03eb79e9bc8fba16d52392382d7e7415253a7cd4c06a62fb4c6447611d8e06685a7a3b8bad2182392a33af0524e83e18790a34c9514013a38cff67e10a36
|
data/CHANGELOG.md
CHANGED
@@ -14,3 +14,12 @@
|
|
14
14
|
|
15
15
|
## [0.5.0] - 2022-04-16
|
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
|
23
|
+
|
24
|
+
## [0.8.0] - 2022-05-04
|
25
|
+
- Add support for the Events API
|
data/lib/stannp/client.rb
CHANGED
@@ -38,6 +38,18 @@ module Stannp
|
|
38
38
|
LettersResource.new(client: self)
|
39
39
|
end
|
40
40
|
|
41
|
+
def groups
|
42
|
+
GroupsResource.new(client: self)
|
43
|
+
end
|
44
|
+
|
45
|
+
def campaigns
|
46
|
+
CampaignsResource.new(client: self)
|
47
|
+
end
|
48
|
+
|
49
|
+
def events
|
50
|
+
EventsResource.new(client: self)
|
51
|
+
end
|
52
|
+
|
41
53
|
def connection
|
42
54
|
@connection ||= Faraday.new do |conn|
|
43
55
|
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
|
data/lib/stannp/version.rb
CHANGED
data/lib/stannp.rb
CHANGED
@@ -15,6 +15,9 @@ module Stannp
|
|
15
15
|
autoload :AddressesResource, 'stannp/resources/addresses'
|
16
16
|
autoload :PostcardsResource, 'stannp/resources/postcards'
|
17
17
|
autoload :LettersResource, 'stannp/resources/letters'
|
18
|
+
autoload :GroupsResource, 'stannp/resources/groups'
|
19
|
+
autoload :CampaignsResource, 'stannp/resources/campaigns'
|
20
|
+
autoload :EventsResource, 'stannp/resources/events'
|
18
21
|
# objects
|
19
22
|
autoload :User, 'stannp/objects/user'
|
20
23
|
autoload :Recipient, 'stannp/objects/recipient'
|
@@ -22,4 +25,7 @@ module Stannp
|
|
22
25
|
autoload :Postcard, 'stannp/objects/postcard'
|
23
26
|
autoload :Letter, 'stannp/objects/letter'
|
24
27
|
autoload :Batch, 'stannp/objects/batch'
|
28
|
+
autoload :Group, 'stannp/objects/group'
|
29
|
+
autoload :Campaign, 'stannp/objects/campaign'
|
30
|
+
autoload :CampaignCost, 'stannp/objects/campaign_cost'
|
25
31
|
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.8.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-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -59,6 +59,9 @@ files:
|
|
59
59
|
- lib/stannp/list.rb
|
60
60
|
- lib/stannp/object.rb
|
61
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
|
62
65
|
- lib/stannp/objects/letter.rb
|
63
66
|
- lib/stannp/objects/postcard.rb
|
64
67
|
- lib/stannp/objects/receipt.rb
|
@@ -67,6 +70,9 @@ files:
|
|
67
70
|
- lib/stannp/resource.rb
|
68
71
|
- lib/stannp/resources/account.rb
|
69
72
|
- lib/stannp/resources/addresses.rb
|
73
|
+
- lib/stannp/resources/campaigns.rb
|
74
|
+
- lib/stannp/resources/events.rb
|
75
|
+
- lib/stannp/resources/groups.rb
|
70
76
|
- lib/stannp/resources/letters.rb
|
71
77
|
- lib/stannp/resources/postcards.rb
|
72
78
|
- lib/stannp/resources/recipients.rb
|