stannp 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b75837b9841497a819ff0ecc1540b75cafa29b16694255447eaa214418a4d59
4
- data.tar.gz: '021308c33f745ec2f9d82209fed48ae58c49055f88fa1a25762d1fae7973848c'
3
+ metadata.gz: 9e29851d6d5a2f08247c7840729b21d9da1db101165deae90e43560fabd6db13
4
+ data.tar.gz: 258c841164c6abd4312f156252b9087e6fdc75f55708d874dd99e82d7cf223f8
5
5
  SHA512:
6
- metadata.gz: 90edcb56fa0374f3a1a18b80d442329d3631e42a2a751977e46eaf92d414a092dd6af72945f0a72b4de43c07d0b3f9fa09ae4fd7abffff7be6720f43c6e2e0e6
7
- data.tar.gz: 44cb149dbea1d00ee6106aef2a45ace349c52b9a84ee332cbbe3bd24965abe815b513fb551e0ed97e5b30d1d6838d284cc04ec4b7b59c3dd1da380b5391fe71f
6
+ metadata.gz: '0800d2c215fb73f6f5d559a5e1bd1ff4cc8025cdedd61d452088adc4efa5288c7221a7a35733d5a1a046e9fd96f1cf4f8527d793676560bbca6bedd1602f386b'
7
+ data.tar.gz: 0b92c7ad6ae8f5d6dba704d85c6827e4f9aadd6e10ca9d5a4f5426e963465becc637f411bb2567b790e304d9b7d86f5a3180371c40c17c7b4c2e36f1c8e85618
data/CHANGELOG.md CHANGED
@@ -17,3 +17,6 @@
17
17
 
18
18
  ## [0.6.0] - 2022-04-21
19
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
@@ -42,6 +42,10 @@ module Stannp
42
42
  GroupsResource.new(client: self)
43
43
  end
44
44
 
45
+ def campaigns
46
+ CampaignsResource.new(client: self)
47
+ end
48
+
45
49
  def connection
46
50
  @connection ||= Faraday.new do |conn|
47
51
  conn.url_prefix = BASE_URL
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stannp
4
+ class Campaign < Object; end
5
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stannp
4
+ class CampaignCost < Object; end
5
+ end
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stannp
4
- VERSION = '0.6.0'
4
+ VERSION = '0.7.0'
5
5
  end
data/lib/stannp.rb CHANGED
@@ -16,6 +16,7 @@ module Stannp
16
16
  autoload :PostcardsResource, 'stannp/resources/postcards'
17
17
  autoload :LettersResource, 'stannp/resources/letters'
18
18
  autoload :GroupsResource, 'stannp/resources/groups'
19
+ autoload :CampaignsResource, 'stannp/resources/campaigns'
19
20
  # objects
20
21
  autoload :User, 'stannp/objects/user'
21
22
  autoload :Recipient, 'stannp/objects/recipient'
@@ -24,4 +25,6 @@ module Stannp
24
25
  autoload :Letter, 'stannp/objects/letter'
25
26
  autoload :Batch, 'stannp/objects/batch'
26
27
  autoload :Group, 'stannp/objects/group'
28
+ autoload :Campaign, 'stannp/objects/campaign'
29
+ autoload :CampaignCost, 'stannp/objects/campaign_cost'
27
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.6.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-21 00:00:00.000000000 Z
11
+ date: 2022-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -59,6 +59,8 @@ 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
62
64
  - lib/stannp/objects/group.rb
63
65
  - lib/stannp/objects/letter.rb
64
66
  - lib/stannp/objects/postcard.rb
@@ -68,6 +70,7 @@ files:
68
70
  - lib/stannp/resource.rb
69
71
  - lib/stannp/resources/account.rb
70
72
  - lib/stannp/resources/addresses.rb
73
+ - lib/stannp/resources/campaigns.rb
71
74
  - lib/stannp/resources/groups.rb
72
75
  - lib/stannp/resources/letters.rb
73
76
  - lib/stannp/resources/postcards.rb