stannp 0.5.0 → 0.6.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 +3 -0
- data/lib/stannp/client.rb +4 -0
- data/lib/stannp/objects/group.rb +5 -0
- data/lib/stannp/resource.rb +8 -2
- data/lib/stannp/resources/groups.rb +38 -0
- data/lib/stannp/version.rb +1 -1
- data/lib/stannp.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz: '
|
3
|
+
metadata.gz: 2b75837b9841497a819ff0ecc1540b75cafa29b16694255447eaa214418a4d59
|
4
|
+
data.tar.gz: '021308c33f745ec2f9d82209fed48ae58c49055f88fa1a25762d1fae7973848c'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90edcb56fa0374f3a1a18b80d442329d3631e42a2a751977e46eaf92d414a092dd6af72945f0a72b4de43c07d0b3f9fa09ae4fd7abffff7be6720f43c6e2e0e6
|
7
|
+
data.tar.gz: 44cb149dbea1d00ee6106aef2a45ace349c52b9a84ee332cbbe3bd24965abe815b513fb551e0ed97e5b30d1d6838d284cc04ec4b7b59c3dd1da380b5391fe71f
|
data/CHANGELOG.md
CHANGED
data/lib/stannp/client.rb
CHANGED
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,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,7 @@ 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'
|
18
19
|
# objects
|
19
20
|
autoload :User, 'stannp/objects/user'
|
20
21
|
autoload :Recipient, 'stannp/objects/recipient'
|
@@ -22,4 +23,5 @@ module Stannp
|
|
22
23
|
autoload :Postcard, 'stannp/objects/postcard'
|
23
24
|
autoload :Letter, 'stannp/objects/letter'
|
24
25
|
autoload :Batch, 'stannp/objects/batch'
|
26
|
+
autoload :Group, 'stannp/objects/group'
|
25
27
|
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.6.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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/stannp/list.rb
|
60
60
|
- lib/stannp/object.rb
|
61
61
|
- lib/stannp/objects/batch.rb
|
62
|
+
- lib/stannp/objects/group.rb
|
62
63
|
- lib/stannp/objects/letter.rb
|
63
64
|
- lib/stannp/objects/postcard.rb
|
64
65
|
- lib/stannp/objects/receipt.rb
|
@@ -67,6 +68,7 @@ files:
|
|
67
68
|
- lib/stannp/resource.rb
|
68
69
|
- lib/stannp/resources/account.rb
|
69
70
|
- lib/stannp/resources/addresses.rb
|
71
|
+
- lib/stannp/resources/groups.rb
|
70
72
|
- lib/stannp/resources/letters.rb
|
71
73
|
- lib/stannp/resources/postcards.rb
|
72
74
|
- lib/stannp/resources/recipients.rb
|