seven_api 0.6.0 → 0.6.1
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.
- checksums.yaml +4 -4
- data/.gitignore +7 -6
- data/.idea/inspectionProfiles/Project_Default.xml +5 -5
- data/.idea/ruby-client.iml +48 -13
- data/Gemfile +2 -2
- data/LICENSE +21 -21
- data/README.md +1 -1
- data/Rakefile +5 -5
- data/doc/SevenApi/Client.html +8 -8
- data/doc/SevenApi/Contacts/Action.html +0 -0
- data/doc/SevenApi/Contacts.html +0 -0
- data/doc/SevenApi/Endpoint.html +0 -0
- data/doc/SevenApi/Hooks/Action.html +0 -0
- data/doc/SevenApi/Hooks/EventType.html +0 -0
- data/doc/SevenApi/Hooks/RequestMethod.html +0 -0
- data/doc/SevenApi/Hooks/Validator.html +26 -26
- data/doc/SevenApi/Hooks.html +0 -0
- data/doc/SevenApi/Journal/Type.html +0 -0
- data/doc/SevenApi/Journal/Validator.html +18 -18
- data/doc/SevenApi/Journal.html +0 -0
- data/doc/SevenApi/Lookup/Type.html +0 -0
- data/doc/SevenApi/Lookup.html +0 -0
- data/doc/SevenApi/Resource.html +13 -13
- data/doc/SevenApi/Resources/Analytics.html +2 -2
- data/doc/SevenApi/Resources/Balance.html +2 -2
- data/doc/SevenApi/Resources/Contacts.html +6 -6
- data/doc/SevenApi/Resources/Hooks.html +10 -10
- data/doc/SevenApi/Resources/Journal.html +2 -2
- data/doc/SevenApi/Resources/Lookup.html +8 -8
- data/doc/SevenApi/Resources/Pricing.html +2 -2
- data/doc/SevenApi/Resources/Sms.html +2 -2
- data/doc/SevenApi/Resources/Status.html +2 -2
- data/doc/SevenApi/Resources/Subaccounts.html +18 -18
- data/doc/SevenApi/Resources/ValidateForVoice.html +2 -2
- data/doc/SevenApi/Resources/Voice.html +2 -2
- data/doc/SevenApi/Resources.html +0 -0
- data/doc/SevenApi/Sms/Type.html +0 -0
- data/doc/SevenApi/Sms.html +0 -0
- data/doc/SevenApi/Subaccounts/Action.html +0 -0
- data/doc/SevenApi/Subaccounts/Validator.html +29 -29
- data/doc/SevenApi/Subaccounts.html +0 -0
- data/doc/SevenApi/Util.html +39 -39
- data/doc/SevenApi.html +0 -0
- data/document.sh +3 -0
- data/lib/seven_api/client.rb +32 -32
- data/lib/seven_api/contacts.rb +5 -5
- data/lib/seven_api/endpoint.rb +0 -0
- data/lib/seven_api/hooks.rb +69 -68
- data/lib/seven_api/journal.rb +39 -39
- data/lib/seven_api/lookup.rb +12 -12
- data/lib/seven_api/numbers.rb +9 -9
- data/lib/seven_api/paginated.rb +10 -10
- data/lib/seven_api/rcs.rb +0 -0
- data/lib/seven_api/resource.rb +1 -2
- data/lib/seven_api/resources/analytics.rb +54 -54
- data/lib/seven_api/resources/balance.rb +19 -19
- data/lib/seven_api/resources/contacts.rb +56 -56
- data/lib/seven_api/resources/groups.rb +56 -56
- data/lib/seven_api/resources/hooks.rb +40 -40
- data/lib/seven_api/resources/journal.rb +20 -20
- data/lib/seven_api/resources/lookup.rb +63 -63
- data/lib/seven_api/resources/numbers.rb +70 -69
- data/lib/seven_api/resources/pricing.rb +20 -20
- data/lib/seven_api/resources/rcs.rb +3 -3
- data/lib/seven_api/resources/sms.rb +29 -20
- data/lib/seven_api/resources/status.rb +20 -20
- data/lib/seven_api/resources/subaccounts.rb +65 -65
- data/lib/seven_api/resources/validate_for_voice.rb +20 -20
- data/lib/seven_api/resources/voice.rb +29 -20
- data/lib/seven_api/sms.rb +9 -9
- data/lib/seven_api/subaccounts.rb +55 -55
- data/lib/seven_api/util.rb +68 -68
- data/lib/seven_api/version.rb +5 -5
- data/lib/seven_api.rb +6 -6
- data/release.sh +4 -4
- data/seven_api.gemspec +0 -0
- data/spec/EnvKeyStore.rb +14 -14
- data/spec/matchers.rb +22 -22
- data/spec/seven_api/analytics_spec.rb +49 -49
- data/spec/seven_api/balance_spec.rb +18 -18
- data/spec/seven_api/client_spec.rb +15 -15
- data/spec/seven_api/contacts_spec.rb +100 -100
- data/spec/seven_api/groups_spec.rb +74 -74
- data/spec/seven_api/hooks_spec.rb +108 -108
- data/spec/seven_api/instance_spec.rb +22 -22
- data/spec/seven_api/journal_spec.rb +86 -86
- data/spec/seven_api/lookup_spec.rb +197 -197
- data/spec/seven_api/numbers_spec.rb +135 -135
- data/spec/seven_api/pricing_spec.rb +76 -76
- data/spec/seven_api/rcs_spec.rb +0 -0
- data/spec/seven_api/sms_spec.rb +103 -103
- data/spec/seven_api/subaccounts_spec.rb +121 -121
- data/spec/seven_api/validate_for_voice_spec.rb +19 -19
- data/spec/seven_api/voice_spec.rb +51 -51
- data/spec/seven_api_spec.rb +9 -9
- metadata +4 -6
data/lib/seven_api/hooks.rb
CHANGED
@@ -1,68 +1,69 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# This module holds all utilities related to the /hooks endpoint.
|
4
|
-
module SevenApi::Hooks
|
5
|
-
module Action
|
6
|
-
READ = 'read'
|
7
|
-
SUBSCRIBE = 'subscribe'
|
8
|
-
UNSUBSCRIBE = 'unsubscribe'
|
9
|
-
end
|
10
|
-
|
11
|
-
module EventType
|
12
|
-
ALL = 'all'
|
13
|
-
NEW_INBOUND_SMS = 'sms_mo'
|
14
|
-
RCS = 'rcs'
|
15
|
-
SMS_STATUS_UPDATE = 'dlr'
|
16
|
-
TRACKING = 'tracking'
|
17
|
-
VOICE_CALL = 'voice_call'
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
self.
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This module holds all utilities related to the /hooks endpoint.
|
4
|
+
module SevenApi::Hooks
|
5
|
+
module Action
|
6
|
+
READ = 'read'
|
7
|
+
SUBSCRIBE = 'subscribe'
|
8
|
+
UNSUBSCRIBE = 'unsubscribe'
|
9
|
+
end
|
10
|
+
|
11
|
+
module EventType
|
12
|
+
ALL = 'all'
|
13
|
+
NEW_INBOUND_SMS = 'sms_mo'
|
14
|
+
RCS = 'rcs'
|
15
|
+
SMS_STATUS_UPDATE = 'dlr'
|
16
|
+
TRACKING = 'tracking'
|
17
|
+
VOICE_CALL = 'voice_call'
|
18
|
+
VOICE_DTMF = 'voice_dtmf'
|
19
|
+
VOICE_STATUS_UPDATE = 'voice_status'
|
20
|
+
end
|
21
|
+
|
22
|
+
module RequestMethod
|
23
|
+
GET = 'GET'
|
24
|
+
JSON = 'JSON'
|
25
|
+
POST = 'POST'
|
26
|
+
end
|
27
|
+
|
28
|
+
module Validator
|
29
|
+
def self.validate(params)
|
30
|
+
action = params[:action]
|
31
|
+
|
32
|
+
raise "Unknown action #{action}" unless SevenApi::Hooks::Validator::is_action?(action)
|
33
|
+
|
34
|
+
if SevenApi::Hooks::Action::SUBSCRIBE == action
|
35
|
+
raise 'Parameter validation failed' unless SevenApi::Hooks::Validator::subscribe(params)
|
36
|
+
elsif SevenApi::Hooks::Action::UNSUBSCRIBE == action
|
37
|
+
raise 'ID must be a positive integer' unless SevenApi::Hooks::Validator::unsubscribe(params)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.subscribe(params)
|
42
|
+
{ :request_method => SevenApi::Hooks::RequestMethod::POST }.merge!(params)
|
43
|
+
|
44
|
+
self.event_type?(params[:event_type]) &&
|
45
|
+
self.request_method?(params[:request_method]) &&
|
46
|
+
self.target_url?(params[:target_url])
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.unsubscribe(params)
|
50
|
+
SevenApi::Util::is_positive_integer?(params[:id])
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.is_action?(str)
|
54
|
+
SevenApi::Util::in_module_constants?(str, SevenApi::Hooks::Action)
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.event_type?(str)
|
58
|
+
SevenApi::Util::in_module_constants?(str, SevenApi::Hooks::EventType)
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.request_method?(str)
|
62
|
+
SevenApi::Util::in_module_constants?(str, SevenApi::Hooks::RequestMethod)
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.target_url?(str)
|
66
|
+
SevenApi::Util::is_valid_url?(str)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/seven_api/journal.rb
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# This module holds all utilities related to the /journal endpoint.
|
4
|
-
module SevenApi::Journal
|
5
|
-
module Type
|
6
|
-
INBOUND = 'inbound'
|
7
|
-
OUTBOUND = 'outbound'
|
8
|
-
REPLIES = 'replies'
|
9
|
-
VOICE = 'voice'
|
10
|
-
end
|
11
|
-
|
12
|
-
module Validator
|
13
|
-
def self.validate(params)
|
14
|
-
type = params[:type]
|
15
|
-
date_from = params[:date_from]
|
16
|
-
date_to = params[:date_to]
|
17
|
-
|
18
|
-
raise "Unknown type #{type}" unless SevenApi::Journal::Validator::is_type?(type)
|
19
|
-
raise "Wrong date_from #{date_from}" unless SevenApi::Journal::Validator::is_date?(date_from)
|
20
|
-
raise "Wrong date_to #{date_to}" unless SevenApi::Journal::Validator::is_date?(date_to)
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.subscribe(params)
|
24
|
-
{ :request_method => SevenApi::Hooks::RequestMethod::POST }.merge!(params)
|
25
|
-
|
26
|
-
self.event_type?(params[:event_type]) &&
|
27
|
-
self.request_method?(params[:request_method]) &&
|
28
|
-
self.target_url?(params[:target_url])
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.is_type?(str)
|
32
|
-
SevenApi::Util::in_module_constants?(str, SevenApi::Journal::Type)
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.is_date?(date)
|
36
|
-
date.is_a?(NilClass) || date.match(/[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])/)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This module holds all utilities related to the /journal endpoint.
|
4
|
+
module SevenApi::Journal
|
5
|
+
module Type
|
6
|
+
INBOUND = 'inbound'
|
7
|
+
OUTBOUND = 'outbound'
|
8
|
+
REPLIES = 'replies'
|
9
|
+
VOICE = 'voice'
|
10
|
+
end
|
11
|
+
|
12
|
+
module Validator
|
13
|
+
def self.validate(params)
|
14
|
+
type = params[:type]
|
15
|
+
date_from = params[:date_from]
|
16
|
+
date_to = params[:date_to]
|
17
|
+
|
18
|
+
raise "Unknown type #{type}" unless SevenApi::Journal::Validator::is_type?(type)
|
19
|
+
raise "Wrong date_from #{date_from}" unless SevenApi::Journal::Validator::is_date?(date_from)
|
20
|
+
raise "Wrong date_to #{date_to}" unless SevenApi::Journal::Validator::is_date?(date_to)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.subscribe(params)
|
24
|
+
{ :request_method => SevenApi::Hooks::RequestMethod::POST }.merge!(params)
|
25
|
+
|
26
|
+
self.event_type?(params[:event_type]) &&
|
27
|
+
self.request_method?(params[:request_method]) &&
|
28
|
+
self.target_url?(params[:target_url])
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.is_type?(str)
|
32
|
+
SevenApi::Util::in_module_constants?(str, SevenApi::Journal::Type)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.is_date?(date)
|
36
|
+
date.is_a?(NilClass) || date.match(/[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])/)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/seven_api/lookup.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# This module holds all utilities related to the /lookup endpoint.
|
4
|
-
module SevenApi::Lookup
|
5
|
-
module Type
|
6
|
-
CNAM = 'cnam'
|
7
|
-
FORMAT = 'format'
|
8
|
-
HLR = 'hlr'
|
9
|
-
MNP = 'mnp'
|
10
|
-
RCS = 'rcs'
|
11
|
-
end
|
12
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This module holds all utilities related to the /lookup endpoint.
|
4
|
+
module SevenApi::Lookup
|
5
|
+
module Type
|
6
|
+
CNAM = 'cnam'
|
7
|
+
FORMAT = 'format'
|
8
|
+
HLR = 'hlr'
|
9
|
+
MNP = 'mnp'
|
10
|
+
RCS = 'rcs'
|
11
|
+
end
|
12
|
+
end
|
data/lib/seven_api/numbers.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# This module holds all utilities related to the /numbers endpoint.
|
4
|
-
module SevenApi::Numbers
|
5
|
-
module PaymentInterval
|
6
|
-
ANNUALLY = 'annually'
|
7
|
-
MONTHLY = 'monthly'
|
8
|
-
end
|
9
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This module holds all utilities related to the /numbers endpoint.
|
4
|
+
module SevenApi::Numbers
|
5
|
+
module PaymentInterval
|
6
|
+
ANNUALLY = 'annually'
|
7
|
+
MONTHLY = 'monthly'
|
8
|
+
end
|
9
|
+
end
|
data/lib/seven_api/paginated.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SevenApi
|
4
|
-
module Paginated
|
5
|
-
module OrderDirection
|
6
|
-
ASCENDING = 'asc'
|
7
|
-
DESCENDING = 'desc'
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SevenApi
|
4
|
+
module Paginated
|
5
|
+
module OrderDirection
|
6
|
+
ASCENDING = 'asc'
|
7
|
+
DESCENDING = 'desc'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/lib/seven_api/rcs.rb
CHANGED
File without changes
|
data/lib/seven_api/resource.rb
CHANGED
@@ -25,9 +25,8 @@ module SevenApi
|
|
25
25
|
|
26
26
|
protected
|
27
27
|
|
28
|
-
def request(payload = {}, query = {}, path = '')
|
28
|
+
def request(http_method, payload = {}, query = {}, path = '')
|
29
29
|
path = "#{@endpoint}#{path}"
|
30
|
-
http_method = @http_methods[caller_locations.first.label.to_sym]
|
31
30
|
|
32
31
|
if :get == http_method
|
33
32
|
query = payload
|
@@ -1,54 +1,54 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'seven_api/resource'
|
4
|
-
|
5
|
-
# This module exposes the methods for communicating with the API endpoint /analytics.
|
6
|
-
module SevenApi::Resources
|
7
|
-
class Analytics < SevenApi::Resource
|
8
|
-
@endpoint = SevenApi::Endpoint::ANALYTICS
|
9
|
-
PATHS = {
|
10
|
-
:by_country => "/country",
|
11
|
-
:by_date => "/date",
|
12
|
-
:by_label => "/label",
|
13
|
-
:by_subaccount => "/subaccount",
|
14
|
-
}
|
15
|
-
@http_methods = {
|
16
|
-
:by_country => :get,
|
17
|
-
:by_date => :get,
|
18
|
-
:by_label => :get,
|
19
|
-
:by_subaccount => :get,
|
20
|
-
}
|
21
|
-
|
22
|
-
# Retrieve analytics grouped by country
|
23
|
-
# read more: https://docs.seven.io/en/rest-api/endpoints/account#statistics
|
24
|
-
# @param params [Hash]
|
25
|
-
# @return [Array]
|
26
|
-
def by_country(params = {})
|
27
|
-
request({}, params, PATHS[:by_country])
|
28
|
-
end
|
29
|
-
|
30
|
-
# Retrieve analytics grouped by date
|
31
|
-
# read more: https://docs.seven.io/en/rest-api/endpoints/account#statistics
|
32
|
-
# @param params [Hash]
|
33
|
-
# @return [Array]
|
34
|
-
def by_date(params = {})
|
35
|
-
request({}, params, PATHS[:by_date])
|
36
|
-
end
|
37
|
-
|
38
|
-
# Retrieve analytics grouped by label
|
39
|
-
# read more: https://docs.seven.io/en/rest-api/endpoints/account#statistics
|
40
|
-
# @param params [Hash]
|
41
|
-
# @return [Array]
|
42
|
-
def by_label(params = {})
|
43
|
-
request({}, params, PATHS[:by_label])
|
44
|
-
end
|
45
|
-
|
46
|
-
# Retrieve analytics grouped by subaccount
|
47
|
-
# read more: https://docs.seven.io/en/rest-api/endpoints/account#statistics
|
48
|
-
# @param params [Hash]
|
49
|
-
# @return [Array]
|
50
|
-
def by_subaccount(params = {})
|
51
|
-
request({}, params, PATHS[:by_subaccount])
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'seven_api/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /analytics.
|
6
|
+
module SevenApi::Resources
|
7
|
+
class Analytics < SevenApi::Resource
|
8
|
+
@endpoint = SevenApi::Endpoint::ANALYTICS
|
9
|
+
PATHS = {
|
10
|
+
:by_country => "/country",
|
11
|
+
:by_date => "/date",
|
12
|
+
:by_label => "/label",
|
13
|
+
:by_subaccount => "/subaccount",
|
14
|
+
}
|
15
|
+
@http_methods = {
|
16
|
+
:by_country => :get,
|
17
|
+
:by_date => :get,
|
18
|
+
:by_label => :get,
|
19
|
+
:by_subaccount => :get,
|
20
|
+
}
|
21
|
+
|
22
|
+
# Retrieve analytics grouped by country
|
23
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/account#statistics
|
24
|
+
# @param params [Hash]
|
25
|
+
# @return [Array]
|
26
|
+
def by_country(params = {})
|
27
|
+
request(:get, {}, params, PATHS[:by_country])
|
28
|
+
end
|
29
|
+
|
30
|
+
# Retrieve analytics grouped by date
|
31
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/account#statistics
|
32
|
+
# @param params [Hash]
|
33
|
+
# @return [Array]
|
34
|
+
def by_date(params = {})
|
35
|
+
request(:get,{}, params, PATHS[:by_date])
|
36
|
+
end
|
37
|
+
|
38
|
+
# Retrieve analytics grouped by label
|
39
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/account#statistics
|
40
|
+
# @param params [Hash]
|
41
|
+
# @return [Array]
|
42
|
+
def by_label(params = {})
|
43
|
+
request(:get,{}, params, PATHS[:by_label])
|
44
|
+
end
|
45
|
+
|
46
|
+
# Retrieve analytics grouped by subaccount
|
47
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/account#statistics
|
48
|
+
# @param params [Hash]
|
49
|
+
# @return [Array]
|
50
|
+
def by_subaccount(params = {})
|
51
|
+
request(:get,{}, params, PATHS[:by_subaccount])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'seven_api/resource'
|
4
|
-
|
5
|
-
# This module exposes the methods for communicating with the API endpoint /balance.
|
6
|
-
module SevenApi::Resources
|
7
|
-
class Balance < SevenApi::Resource
|
8
|
-
@endpoint = SevenApi::Endpoint::BALANCE
|
9
|
-
@http_methods = {
|
10
|
-
:retrieve => :get,
|
11
|
-
}
|
12
|
-
|
13
|
-
# Retrieve account balance for associated API key
|
14
|
-
# read more: https://docs.seven.io/en/rest-api/endpoints/account#balance
|
15
|
-
# @return [Hash]
|
16
|
-
def retrieve
|
17
|
-
request
|
18
|
-
end
|
19
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'seven_api/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /balance.
|
6
|
+
module SevenApi::Resources
|
7
|
+
class Balance < SevenApi::Resource
|
8
|
+
@endpoint = SevenApi::Endpoint::BALANCE
|
9
|
+
@http_methods = {
|
10
|
+
:retrieve => :get,
|
11
|
+
}
|
12
|
+
|
13
|
+
# Retrieve account balance for associated API key
|
14
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/account#balance
|
15
|
+
# @return [Hash]
|
16
|
+
def retrieve
|
17
|
+
request(:get)
|
18
|
+
end
|
19
|
+
end
|
20
20
|
end
|
@@ -1,57 +1,57 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'seven_api/resource'
|
4
|
-
|
5
|
-
# This module exposes the methods for communicating with the API endpoint /contacts.
|
6
|
-
module SevenApi::Resources
|
7
|
-
class Contacts < SevenApi::Resource
|
8
|
-
@endpoint = SevenApi::Endpoint::CONTACTS
|
9
|
-
@http_methods = {
|
10
|
-
:all => :get,
|
11
|
-
:create => :post,
|
12
|
-
:delete => :delete,
|
13
|
-
:one => :get,
|
14
|
-
:update => :patch,
|
15
|
-
}
|
16
|
-
|
17
|
-
# Retrieve contacts associated with the API key
|
18
|
-
# read more: https://docs.seven.io/en/rest-api/endpoints/contacts#query-contact-list
|
19
|
-
# @param params [Hash]
|
20
|
-
# @return [Hash]
|
21
|
-
def all(params = {})
|
22
|
-
request(params)
|
23
|
-
end
|
24
|
-
|
25
|
-
# Retrieve a contact associated with the API key
|
26
|
-
# read more: https://docs.seven.io/en/rest-api/endpoints/contacts#retrieve-contact
|
27
|
-
# @param id [Int]
|
28
|
-
# @return [Hash]
|
29
|
-
def one(id)
|
30
|
-
request({}, {}, "/#{id}")
|
31
|
-
end
|
32
|
-
|
33
|
-
# Delete a contact with given ID
|
34
|
-
# read more: https://docs.seven.io/en/rest-api/endpoints/contacts#delete-contact
|
35
|
-
# @param id [Integer]
|
36
|
-
# @return [Hash]
|
37
|
-
def delete(id)
|
38
|
-
request({}, {}, "/#{id}")
|
39
|
-
end
|
40
|
-
|
41
|
-
# Create a contact
|
42
|
-
# read more: https://docs.seven.io/en/rest-api/endpoints/contacts#create-contact
|
43
|
-
# @param params [Hash]
|
44
|
-
# @return [Hash]
|
45
|
-
def create(params)
|
46
|
-
request( params)
|
47
|
-
end
|
48
|
-
|
49
|
-
# Update a contact
|
50
|
-
# read more: https://docs.seven.io/en/rest-api/endpoints/contacts#update-contact
|
51
|
-
# @param contact [Hash]
|
52
|
-
# @return [Hash]
|
53
|
-
def update(contact)
|
54
|
-
request(contact, {}, "/#{contact['id']}")
|
55
|
-
end
|
56
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'seven_api/resource'
|
4
|
+
|
5
|
+
# This module exposes the methods for communicating with the API endpoint /contacts.
|
6
|
+
module SevenApi::Resources
|
7
|
+
class Contacts < SevenApi::Resource
|
8
|
+
@endpoint = SevenApi::Endpoint::CONTACTS
|
9
|
+
@http_methods = {
|
10
|
+
:all => :get,
|
11
|
+
:create => :post,
|
12
|
+
:delete => :delete,
|
13
|
+
:one => :get,
|
14
|
+
:update => :patch,
|
15
|
+
}
|
16
|
+
|
17
|
+
# Retrieve contacts associated with the API key
|
18
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/contacts#query-contact-list
|
19
|
+
# @param params [Hash]
|
20
|
+
# @return [Hash]
|
21
|
+
def all(params = {})
|
22
|
+
request(:get, params)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Retrieve a contact associated with the API key
|
26
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/contacts#retrieve-contact
|
27
|
+
# @param id [Int]
|
28
|
+
# @return [Hash]
|
29
|
+
def one(id)
|
30
|
+
request(:get,{}, {}, "/#{id}")
|
31
|
+
end
|
32
|
+
|
33
|
+
# Delete a contact with given ID
|
34
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/contacts#delete-contact
|
35
|
+
# @param id [Integer]
|
36
|
+
# @return [Hash]
|
37
|
+
def delete(id)
|
38
|
+
request({}, {}, "/#{id}")
|
39
|
+
end
|
40
|
+
|
41
|
+
# Create a contact
|
42
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/contacts#create-contact
|
43
|
+
# @param params [Hash]
|
44
|
+
# @return [Hash]
|
45
|
+
def create(params)
|
46
|
+
request( :post, params)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Update a contact
|
50
|
+
# read more: https://docs.seven.io/en/rest-api/endpoints/contacts#update-contact
|
51
|
+
# @param contact [Hash]
|
52
|
+
# @return [Hash]
|
53
|
+
def update(contact)
|
54
|
+
request(:patch, contact, {}, "/#{contact['id']}")
|
55
|
+
end
|
56
|
+
end
|
57
57
|
end
|