vivialconnect 0.0.1 → 0.0.2
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/lib/vivialconnect/account.rb +2 -146
- data/lib/vivialconnect/client.rb +6 -12
- data/lib/vivialconnect/number.rb +27 -0
- data/lib/vivialconnect/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e65db123633edbb42c7bb154aaa83b71074e126
|
4
|
+
data.tar.gz: a1e4578831432c28d121f12ea6a5f0f0bc078d39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e338e4bbd2d960f563717311b10c21b4ef10c9c1f55ff80c3805917c7574779fb700da2e4d1df0c6495db5dcd178ab4e22ad7ad95db21ef72149d40ca53d97f
|
7
|
+
data.tar.gz: 1dd0267470a00d5861c7d122cdd6e8bf311f0e7f5c54819e5052be5736232b00ce413c1f013249b18924a5ccd14cdc02d61a0862db479846a5ffd77b47fb31aa
|
@@ -1,66 +1,8 @@
|
|
1
1
|
module VivialConnect
|
2
|
-
##
|
3
|
-
#=== .add_main_contact_to_subaccount(options={})
|
4
|
-
#
|
5
|
-
#Creates a new contact and adds it as the main contact to a subaccount.
|
6
|
-
#
|
7
|
-
# Required parameters:
|
8
|
-
#
|
9
|
-
# account_id | Fixnum | 123456 (subaccount id)
|
10
|
-
# company_name | String | "App Developer Inc."
|
11
|
-
# first_name | String | "Bob"
|
12
|
-
# last_name | String | "Tester"
|
13
|
-
# email | String | "btester@vivialconnect"
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# Optional parameters:
|
17
|
-
#
|
18
|
-
# address1 | String | "500 Office Building Ln"
|
19
|
-
# address2 | String | "Suite 300"
|
20
|
-
# address3 | String | "c/o Front Desk"
|
21
|
-
# city | String | "Columbia Heights"
|
22
|
-
# country | String | "United States"
|
23
|
-
# state | String | "Minnesota"
|
24
|
-
# postal_code | String | "55421"
|
25
|
-
# title | String | "CMO"
|
26
|
-
# work_phone | String | "+1XXXXXXXXXX"
|
27
|
-
# mobile_phone | String | "+1XXXXXXXXXX"
|
28
|
-
# fax | String | "+1XXXXXXXXXX"
|
29
|
-
#
|
30
|
-
# Example Usage
|
31
|
-
#
|
32
|
-
#
|
33
|
-
# VivialConnect::Account.add_main_contact_to_subaccount(email: "btester@vivialconnect", contact_type:"main", company_name: "Acme")
|
34
|
-
# => #<VivialConnect::Contact account_id=1XXXX, active=true, address1=nil, address2=nil, address3=nil, city=nil, company_name="Acme", contact_type="main", country="United States", date_created="2017-04-21T10:51:50-04:00", date_modified="2017-04-21T10:51:50-04:00", email="btester@vivialconnect", fax=nil, first_name="Bob", id=89, last_name="Tester", mobile_phone=nil, postal_code="55421", state=nil, title=nil, work_phone="+1XXXXXXXXXX">
|
35
|
-
#
|
36
|
-
#
|
37
|
-
##
|
38
|
-
#=== .add_user_to_subaccount(options={})
|
39
|
-
#
|
40
|
-
#Creates a new User and adds it to a subaccount.
|
41
|
-
#
|
42
|
-
#
|
43
|
-
# Required parameters:
|
44
|
-
#
|
45
|
-
#
|
46
|
-
# first_name | String | "Bob"
|
47
|
-
# last_name | String | "Tester"
|
48
|
-
# email | String | "btester@vivialconnect"
|
49
|
-
# username | String | "btester"
|
50
|
-
# password | String | "dlrowolleh"
|
51
|
-
#
|
52
|
-
#
|
53
|
-
# Example Usage
|
54
|
-
#
|
55
|
-
#
|
56
|
-
# VivialConnect::Account.add_user_to_subaccount(account_id: 1XXXX, email: "btester@vivialconnect.net", username: "btester", first_name: "Bob", last_name: "Tester", password: "XXXXXXX")
|
57
|
-
# => #<VivialConnect::User account_id=1XXXX, active=true, api_key="XYZYXZYXYZXYXZYXZYXYZYXYZYXYZYXYZYX", date_created="2017-04-21T11:27:16-04:00", date_modified="2017-04-21T11:27:16-04:00", email="btester@vivialconnect.net", first_name="Bob", id=10093, last_name="Tester", roles=[{"active"=>true, "date_created"=>"2016-09-30T19:42:59-04:00", "date_modified"=>"2016-09-30T19:42:59-04:00", "description"=>"User role", "id"=>4, "name"=>"User", "role_type"=>"client"}], timezone="US/Eastern", username="btester", verified=false>
|
58
|
-
#
|
59
|
-
# Note: This method triggers an email to the created user's account. They need to answer this confirmation email before they will be able to log in.
|
60
2
|
##
|
61
3
|
#=== .all
|
62
4
|
#
|
63
|
-
#Returns an array containing ruby objects corresponding to all Account resources associated with your account
|
5
|
+
#Returns an array containing ruby objects corresponding to all Account resources associated with your account
|
64
6
|
#
|
65
7
|
#
|
66
8
|
# Example usage:
|
@@ -82,28 +24,6 @@ module VivialConnect
|
|
82
24
|
#
|
83
25
|
#
|
84
26
|
##
|
85
|
-
#=== .create(options={})
|
86
|
-
#
|
87
|
-
#Creates a subaccount tied to your main account
|
88
|
-
#
|
89
|
-
#
|
90
|
-
# Required parameters:
|
91
|
-
#
|
92
|
-
#
|
93
|
-
# company_name | String | "App Developer Inc."
|
94
|
-
#
|
95
|
-
#
|
96
|
-
# Example Usage
|
97
|
-
#
|
98
|
-
#
|
99
|
-
# VivialConnect::Account.create(company_name: "App Developer Inc.")
|
100
|
-
# => #<VivialConnect::Account account_id=1XXXX, accounts=[], active=true, company_name="App Developer Inc.", contacts=[], date_created="2017-04-20T17:07:08-04:00", date_modified="2017-04-20T17:07:08-04:00", id=10086, services=[{"active"=>true, "date_created"=>"2016-09-30T19:42:58-04:00", "date_modified"=>"2016-09-30T19:42:58-04:00", "description"=>"SMS service", "id"=>1, "name"=>"sms", "service_type"=>"client"}, {"active"=>true, "date_created"=>"2016-09-30T19:42:58-04:00", "date_modified"=>"2016-09-30T19:42:58-04:00", "description"=>"Account service", "id"=>2, "name"=>"accounts", "service_type"=>"client"}, {"active"=>true, "date_created"=>"2016-09-30T19:42:58-04:00", "date_modified"=>"2016-09-30T19:42:58-04:00", "description"=>"Public service", "id"=>3, "name"=>"public", "service_type"=>"client"}]>
|
101
|
-
#
|
102
|
-
#
|
103
|
-
# Note: When creating subaccounts, the `id` refers to the subaccount id, whereas the `account_id` refers to the main account.
|
104
|
-
#
|
105
|
-
#
|
106
|
-
##
|
107
27
|
#=== .find(id)
|
108
28
|
#
|
109
29
|
#Returns the a Account object referenced by the `id` value.
|
@@ -191,19 +111,6 @@ module VivialConnect
|
|
191
111
|
#
|
192
112
|
#
|
193
113
|
##
|
194
|
-
#=== .subaccounts
|
195
|
-
#
|
196
|
-
#Returns an array containing ruby objects containing all associated subaccounts
|
197
|
-
#
|
198
|
-
#
|
199
|
-
# Example usage:
|
200
|
-
#
|
201
|
-
#
|
202
|
-
# VivialConnect::Account.subaccounts
|
203
|
-
# => [#<VivialConnect::Account>, #<VivialConnect::Account>, #<VivialConnect::Account>]
|
204
|
-
#
|
205
|
-
#
|
206
|
-
##
|
207
114
|
#=== .update(id, options={})
|
208
115
|
#
|
209
116
|
# Required parameters:
|
@@ -218,59 +125,8 @@ module VivialConnect
|
|
218
125
|
# => #<VivialConnect::Account account_id=1XXXX, accounts=[], active=true, company_name="New Name", contacts=[], date_created="2017-04-20T17:07:08-04:00", date_modified="2017-04-20T17:07:08-04:00", id=10086, services=[{"active"=>true, "date_created"=>"2016-09-30T19:42:58-04:00", "date_modified"=>"2016-09-30T19:42:58-04:00", "description"=>"SMS service", "id"=>1, "name"=>"sms", "service_type"=>"client"}, {"active"=>true, "date_created"=>"2016-09-30T19:42:58-04:00", "date_modified"=>"2016-09-30T19:42:58-04:00", "description"=>"Account service", "id"=>2, "name"=>"accounts", "service_type"=>"client"}, {"active"=>true, "date_created"=>"2016-09-30T19:42:58-04:00", "date_modified"=>"2016-09-30T19:42:58-04:00", "description"=>"Public service", "id"=>3, "name"=>"public", "service_type"=>"client"}]>
|
219
126
|
#
|
220
127
|
#
|
221
|
-
##
|
222
|
-
#=== \#save
|
223
|
-
#
|
224
|
-
# Creates a subaccount associated with your main account or updates an existing one
|
225
|
-
#
|
226
|
-
#
|
227
|
-
# Example usage:
|
228
|
-
#
|
229
|
-
# account = VivialConnect::Account.new
|
230
|
-
# account.company_name = "B Tester QA Inc."
|
231
|
-
# account.save
|
232
|
-
# => #<VivialConnect::Account account_id=1XXXX, accounts=[], active=true, company_name="B Tester QA Inc.", contacts=[], date_created="2017-04-20T17:07:08-04:00", date_modified="2017-04-20T17:07:08-04:00", id=10086, services=[{"active"=>true, "date_created"=>"2016-09-30T19:42:58-04:00", "date_modified"=>"2016-09-30T19:42:58-04:00", "description"=>"SMS service", "id"=>1, "name"=>"sms", "service_type"=>"client"}, {"active"=>true, "date_created"=>"2016-09-30T19:42:58-04:00", "date_modified"=>"2016-09-30T19:42:58-04:00", "description"=>"Account service", "id"=>2, "name"=>"accounts", "service_type"=>"client"}, {"active"=>true, "date_created"=>"2016-09-30T19:42:58-04:00", "date_modified"=>"2016-09-30T19:42:58-04:00", "description"=>"Public service", "id"=>3, "name"=>"public", "service_type"=>"client"}]>
|
233
|
-
#
|
234
|
-
#
|
235
|
-
class Account < Resource
|
236
|
-
|
237
|
-
def self.subaccounts # :nodoc:
|
238
|
-
uri = '/subaccounts.json'
|
239
|
-
VivialConnect::Client.instance.make_request('GET', uri)
|
240
|
-
end
|
241
|
-
|
242
|
-
def self.add_main_contact_to_subaccount(options={}) # :nodoc:
|
243
|
-
raise VivialConnectClientError, "you must include an account_id parameter" if !options.keys.include?(:account_id)
|
244
|
-
|
245
|
-
# This call must be made from the subaccount, so the client's account_id has to be updated
|
246
|
-
main_account_id = VivialConnect::Client.instance.account_id
|
247
|
-
|
248
|
-
VivialConnect::Client.instance.account_id = options[:account_id]
|
249
|
-
uri = '/contacts.json'
|
250
|
-
options[:contact_type] = 'main'
|
251
|
-
data = {}
|
252
|
-
data[:contact] = options
|
253
|
-
data = data.to_json
|
254
128
|
|
255
|
-
|
256
|
-
response = VivialConnect::Client.instance.make_request('POST', uri, data)
|
257
|
-
ensure
|
258
|
-
# client's account_id must be set back for future calls to work
|
259
|
-
VivialConnect::Client.instance.account_id = main_account_id
|
260
|
-
end
|
261
|
-
|
262
|
-
response
|
263
|
-
end
|
264
|
-
|
265
|
-
def self.add_user_to_subaccount(options={}) # :nodoc:
|
266
|
-
raise VivialConnectClientError, "you must include an account_id parameter" if !options.keys.include?(:account_id)
|
267
|
-
uri = '/users/register.json'
|
268
|
-
options[:role] = 'User'
|
269
|
-
data = {}
|
270
|
-
data[:user] = options
|
271
|
-
data = data.to_json
|
272
|
-
response = VivialConnect::Client.instance.make_request('POST', uri, data)
|
273
|
-
end
|
129
|
+
class Account < Resource
|
274
130
|
|
275
131
|
end
|
276
132
|
end
|
data/lib/vivialconnect/client.rb
CHANGED
@@ -34,7 +34,7 @@ module VivialConnect
|
|
34
34
|
# => true
|
35
35
|
#
|
36
36
|
# NOTE: .configure does not check if your credentials are good, it merely checks that you have entered values for them
|
37
|
-
#===
|
37
|
+
#=== #reset
|
38
38
|
#
|
39
39
|
#Resets all of the configuration values to nil. This gives you a blank slate client to call .configure on.
|
40
40
|
#
|
@@ -42,7 +42,7 @@ module VivialConnect
|
|
42
42
|
# Example usage
|
43
43
|
#
|
44
44
|
#
|
45
|
-
# VivialConnect::Client.reset
|
45
|
+
# VivialConnect::Client.instance.reset
|
46
46
|
# => true
|
47
47
|
#
|
48
48
|
#
|
@@ -72,7 +72,6 @@ module VivialConnect
|
|
72
72
|
def initialize
|
73
73
|
begin
|
74
74
|
@base_api_path = host + "#{api_version}/"
|
75
|
-
connection
|
76
75
|
rescue NameError => e
|
77
76
|
raise VivialConnectClientError, "Please configure client before making requests. You can do this like so: .configure(api_key, api_secret, account_id) to "
|
78
77
|
end
|
@@ -88,14 +87,16 @@ module VivialConnect
|
|
88
87
|
true
|
89
88
|
end
|
90
89
|
|
91
|
-
def
|
90
|
+
def reset
|
92
91
|
@@api_key= nil
|
93
92
|
@@api_secret = nil
|
94
93
|
@@account_id = nil
|
95
94
|
@@host = nil
|
96
95
|
@@api_version = nil
|
97
96
|
@@configured = false
|
98
|
-
|
97
|
+
self.instance_variables.each do |ivar|
|
98
|
+
self.remove_instance_variable(ivar)
|
99
|
+
end
|
99
100
|
true
|
100
101
|
end
|
101
102
|
|
@@ -126,7 +127,6 @@ module VivialConnect
|
|
126
127
|
@base_api_path
|
127
128
|
end
|
128
129
|
|
129
|
-
|
130
130
|
def self.configured?
|
131
131
|
@@configured == true
|
132
132
|
end
|
@@ -268,10 +268,6 @@ module VivialConnect
|
|
268
268
|
#return an array of resource objects
|
269
269
|
response_array = api_response[api_response.keys.first]
|
270
270
|
api_response = process_array(response_array, response_class)
|
271
|
-
elsif url.path.split("/")[-1] == "subaccounts.json"
|
272
|
-
#handle subaccounts array
|
273
|
-
response_array = api_response[api_response.keys.first]['accounts']
|
274
|
-
api_response = process_array(response_array, response_class)
|
275
271
|
elsif api_response[api_response.keys[1]].is_a?(Array)
|
276
272
|
#handle Log resource, return last key and an array full of log objects
|
277
273
|
last_key = api_response['last_key']
|
@@ -308,8 +304,6 @@ module VivialConnect
|
|
308
304
|
return Account
|
309
305
|
elsif url.include?('attachments')
|
310
306
|
return Attachment
|
311
|
-
elsif url.include?('subaccounts')
|
312
|
-
return Account
|
313
307
|
else
|
314
308
|
api_resource = url[5]
|
315
309
|
#exceptions needed for resources requiring camelcase
|
data/lib/vivialconnect/number.rb
CHANGED
@@ -254,6 +254,33 @@ module VivialConnect
|
|
254
254
|
# VivialConnect::Number.update(875, name: "Dr. Jones")
|
255
255
|
# => #<VivialConnect::Number account_id=10096, active=true, address_requirements="none", capabilities={"mms"=>true, "sms"=>true, "voice"=>true}, city="ALMELUND", date_created="2017-04-25T10:22:07-04:00", date_modified="2017-04-25T10:41:16-04:00", id=69, lata=nil, master_account_id=1XXXX, message_status_callback=nil, name="Dr. Jones", phone_number="+16123151041", phone_number_type="local", rate_center="TWINCITIES", region="MN", sms_configuration_id=nil, sms_fallback_method=nil, sms_fallback_url=nil, sms_method=nil, sms_url=nil, voice_forwarding_number=nil> #<VivialConnect::Number account_id=1XXXX, active=true, address_requirements="none", capabilities={"mms"=>true, "sms"=>true, "voice"=>true}, city="PITTSBURGH ", date_created="2017-04-25T09:56:04-04:00", date_modified="2017-04-25T09:56:04-04:00", id=66, lata=nil, master_account_id=10096, message_status_callback=nil, name="(412) 433-0365", phone_number="+14124330365", phone_number_type="local", rate_center="PTTSBGZON1", region="PA", sms_configuration_id=nil, sms_fallback_method=nil, sms_fallback_url=nil, sms_method=nil, sms_url=nil, voice_forwarding_number=nil>
|
256
256
|
#
|
257
|
+
#
|
258
|
+
#=== \#delete
|
259
|
+
#
|
260
|
+
# Deletes a Number object. WARNING: this cannot be undone. Once the number is released from your account it can be aquired by other users.
|
261
|
+
#
|
262
|
+
#
|
263
|
+
# Example usage:
|
264
|
+
#
|
265
|
+
#
|
266
|
+
# number = VivialConnect::Number.find(1)
|
267
|
+
# number.delete
|
268
|
+
# => true
|
269
|
+
#
|
270
|
+
#
|
271
|
+
#=== \#save
|
272
|
+
#
|
273
|
+
# Creates a number associated with your main account or updates an existing one
|
274
|
+
#
|
275
|
+
#
|
276
|
+
# Example usage:
|
277
|
+
#
|
278
|
+
# number = VivialConnect::Number.find(2)
|
279
|
+
# number.name = "new name for this number"
|
280
|
+
# number.save
|
281
|
+
# => #<VivialConnect::Number account_id=1XXXX, active=true, address_requirements="none", capabilities={"mms"=>true, "sms"=>true, "voice"=>true}, city="PITTSBURGH ", date_created="2017-04-25T09:56:04-04:00", date_modified="2017-04-25T09:56:04-04:00", id=66, lata=nil, master_account_id=10096, message_status_callback=nil, name="new name for this number", phone_number="+14124330365", phone_number_type="local", rate_center="PTTSBGZON1", region="PA", sms_configuration_id=nil, sms_fallback_method=nil, sms_fallback_url=nil, sms_method=nil, sms_url=nil, voice_forwarding_number=nil>
|
282
|
+
#
|
283
|
+
#
|
257
284
|
|
258
285
|
class Number < Resource
|
259
286
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vivialconnect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin LeFurjah
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
162
|
version: '0'
|
163
163
|
requirements: []
|
164
164
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.6.
|
165
|
+
rubygems_version: 2.6.12
|
166
166
|
signing_key:
|
167
167
|
specification_version: 4
|
168
168
|
summary: This is an API wrapper gem for integrating with the Vivial Connect text messaging
|