vivialconnect 0.0.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.
@@ -0,0 +1,172 @@
1
+ module VivialConnect
2
+ ##
3
+ #=== .all
4
+ #
5
+ #Returns an array containing ruby objects corresponding to all Configuration resources on your account
6
+ #
7
+ #
8
+ # Example usage:
9
+ #
10
+ #
11
+ # VivialConnect::Configuration.all
12
+ # => [#<VivialConnect::Configuration account_id=1XXXX, active=true, date_created="2017-02-06T16:00:52-05:00", date_modified="2017-04-10T11:15:33-04:00", id=12, message_status_callback=nil, name="Message App Config", sms_fallback_method=nil, sms_fallback_url=nil, sms_method="POST", sms_url="http://requestb.in/174w8nz1">]
13
+ #
14
+ #
15
+ #
16
+ #=== .count
17
+ #
18
+ #Returns the amount of Configurations set up on your account
19
+ #
20
+ # Example usage:
21
+ #
22
+ #
23
+ # VivialConnect::Configuration.count
24
+ # => 1
25
+ #
26
+ #
27
+ ##
28
+ #=== .create(options={})
29
+ #
30
+ #Creates and returns a new Configuration
31
+ #
32
+ #
33
+ # Required parameter:
34
+ #
35
+ # name | String | "Taxi App Config"
36
+ #
37
+ #
38
+ # Optional parameters: for MMS
39
+ #
40
+ # phone_number | String | "+1XXXXXXXXXX"
41
+ # message_status_callback | String | "https://myserver.example.com/status"
42
+ # sms_url | String | "https://myserver.example.com/url-for-fielding-incoming-message"
43
+ # sms_method | String | "POST" or "GET" (default is POST)
44
+ # sms_fallback_url | String | "https://myserver.example.com/url-if-sms_url-fails"
45
+ # sms_fallback_method | String | "POST" or "GET" (default is POST)
46
+ #
47
+ # Example Usage
48
+ #
49
+ #
50
+ # VivialConnect::Configuration.create(name: "Taxi Messaging", message_status_callback: "https://myserver.example.com/status")
51
+ # => #<VivialConnect::Configuration account_id=1XXXXX, active=true, date_created="2017-04-21T15:44:28-04:00", date_modified="2017-04-21T15:44:28-04:00", id=55, message_status_callback="https://myserver.example.com/status", name="Taxi Messaging", sms_fallback_method=nil, sms_fallback_url=nil, sms_method=nil, sms_url=nil>
52
+ #
53
+ #
54
+ ##
55
+ #=== .find(id)
56
+ #
57
+ #Returns the a Configuration object referenced by the `id` value.
58
+ #
59
+ # Required parameter:
60
+ #
61
+ # id | Fixnum | the id of the configuration you would like to retrieve
62
+ #
63
+ #
64
+ # Example usage:
65
+ #
66
+ #
67
+ # VivialConnect::Configuration.find(55)
68
+ # => #<VivialConnect::Configuration account_id=1XXXX, active=true, date_created="2017-04-21T15:44:28-04:00", date_modified="2017-04-21T15:44:28-04:00", id=55, message_status_callback="https://myserver.example.com/status", name="Taxi Messaging", sms_fallback_method=nil, sms_fallback_url=nil, sms_method=nil, sms_url=nil>
69
+ #
70
+ #
71
+ ##
72
+ #=== .find_each(start: 1, finish: nil, batch_size: 150)
73
+ #
74
+ #Iterates through all of the configurations on your account in N sized batches beginning at the `start: value` and ending at the `finish: value`.
75
+ #
76
+ #
77
+ # When a block is given this method yields an individual Configuration object.
78
+ # Without a block, this method returns an Enumerator.
79
+ #
80
+ #
81
+ # By default, it will begin at the first configuration and end at the last configuration
82
+ #
83
+ #
84
+ # With default batch_size: 150, if you wanted to get your records from
85
+ # 150 to 300 you would start at 2 and finish at 2.
86
+ #
87
+ #
88
+ #Returns an Array of objects corresponding to the `start` and `finish` values. Default is all objects.
89
+ #
90
+ # Optional parameters:
91
+ #
92
+ # start | Fixnum | batch to start with
93
+ # finish | Fixnum | batch to end with
94
+ # batch_size | Fixnum | between 1..150
95
+ #
96
+ #
97
+ #
98
+ # Example usage:
99
+ #
100
+ #
101
+ # VivialConnect::Configuration.find_each {|configuration| puts configuration.name}
102
+ # Taxi Messaging
103
+ # => [#<VivialConnect::Configuration account_id=1XXXX, active=true, date_created="2017-04-21T15:44:28-04:00", date_modified="2017-04-21T15:44:28-04:00", id=55, message_status_callback="https://myserver.example.com/status", name="Taxi Messaging", sms_fallback_method=nil, sms_fallback_url=nil, sms_method=nil, sms_url=nil>, ...]
104
+ #
105
+ #
106
+ #
107
+ #
108
+ ##
109
+ #=== .find_in_batches(start: 1, finish: nil, batch_size: 150)
110
+ #
111
+ #Iterates through all of the configurations on your account in N sized batches beginning at the `start: value` and ending at the `finish: value`.
112
+ #
113
+ #
114
+ # When a block is given this method yields an array of batch_size resource objects.
115
+ # Without a block, it returns an Enumerator.
116
+ #
117
+ #
118
+ # By default, it will begin at the first configuration and end at the last configuration
119
+ #
120
+ #
121
+ # With default batch_size: 150, if you wanted to get your records from
122
+ # 150 to 300 you would start at 2 and finish at 2.
123
+ #
124
+ #
125
+ # Returns an Array of objects corresponding to the `start` and `finish` values. Default is all objects.
126
+ #
127
+ # Optional parameters:
128
+ #
129
+ # start | Fixnum | batch to start with
130
+ # finish | Fixnum | batch to end with
131
+ # batch_size | Fixnum | between 1..150
132
+ #
133
+ #
134
+ # Example usage:
135
+ #
136
+ #
137
+ # VivialConnect::Configuration.find_in_batches {|batch| do_something_with_an_array(batch)}
138
+ # => [#<VivialConnect::Configuration account_id=1XXXX, active=true, date_created="2017-04-21T15:44:28-04:00", date_modified="2017-04-21T15:44:28-04:00", id=55, message_status_callback="https://myserver.example.com/status", name="Taxi Messaging", sms_fallback_method=nil, sms_fallback_url=nil, sms_method=nil, sms_url=nil>, ...]
139
+ #
140
+ #
141
+ #=== \#delete
142
+ #
143
+ # Deletes a Configuration object
144
+ #
145
+ #
146
+ # Example usage:
147
+ #
148
+ #
149
+ # configuration = VivialConnect::Configuration.find(55)
150
+ # configuration.delete
151
+ # => true
152
+ #
153
+ #
154
+ #=== \#save
155
+ #
156
+ # Creates a Configuration or updates an existing one
157
+ #
158
+ #
159
+ # Example usage:
160
+ #
161
+ #
162
+ # configuration = VivialConnect::Configuration.new
163
+ # configuration.name = "Taxi Messaging"
164
+ # configuration.message_status_callback = "https://myserver.example.com/status"
165
+ # configuration.save
166
+ # => #<VivialConnect::Configuration account_id=1XXXX, active=true, date_created="2017-04-21T15:44:28-04:00", date_modified="2017-04-21T15:44:28-04:00", id=55, message_status_callback="https://myserver.example.com/status", name="Taxi Messaging", sms_fallback_method=nil, sms_fallback_url=nil, sms_method=nil, sms_url=nil>
167
+ #
168
+ #
169
+
170
+ class Configuration < Resource
171
+ end
172
+ end
@@ -0,0 +1,4 @@
1
+ module VivialConnect
2
+ class Contact < Resource # :nodoc:
3
+ end
4
+ end
@@ -0,0 +1,71 @@
1
+ module VivialConnect
2
+ #=== .find_aggregate_by_time(options = {})
3
+ #
4
+ #Returns an array where index 0 is the last_key and index 1 is the array of log_items requested
5
+ #
6
+ #
7
+ # Required parameters:
8
+ #
9
+ # start_time | String | "20170424T134023Z" <-- ISO 8601 strftime('%Y%m%dT%H%M%SZ')
10
+ # end_time | String | "20170425T134023Z" <-- ISO 8601 strftime('%Y%m%dT%H%M%SZ')
11
+ #
12
+ #
13
+ # Optional parameters:
14
+ #
15
+ # logtype | String | The log type, as a string. log-types are typically of the form ITEM_TYPE.ACTION, where ITEM_TYPE is the type of item that was affected and ACTION is what happened to it. For example, message.queued.
16
+ # aggregator_type | String | If present with valid values ("minutes", "hours", "days", "months", "years"), then it will give aggregate map. Else it will give aggregate total counts. Valid values are: minutes, hours, days, months, years
17
+ # operator_id | Fixnum | Unique id of operator that caused this log.
18
+ # limit | Fixnum | Used for pagination, number of log records to return
19
+ # start_key | Fixnum | Used for pagination, value of last_key from previous response
20
+ #
21
+ # Example usage:
22
+ #
23
+ # last_key, log_items = VivialConnect::Log.find_aggregate_by_time(start_time: "20170220T204352Z", end_time: "20170421T204352Z", aggregator_type: "minutes")
24
+ # => ['7b226163...', [ #<VivialConnect::Log>, #<VivialConnect::Log>, #<VivialConnect::Log> ]]
25
+ #
26
+ ##
27
+ #=== .find_by_time(options = {})
28
+ #
29
+ #Returns an array where index 0 is the last_key and index 1 is the array of log_items requested
30
+ #
31
+ #
32
+ # Required parameters:
33
+ #
34
+ # start_time | String | "20170424T134023Z" <-- ISO 8601 strftime('%Y%m%dT%H%M%SZ')
35
+ # end_time | String | "20170425T134023Z" <-- ISO 8601 strftime('%Y%m%dT%H%M%SZ')
36
+ #
37
+ #
38
+ # Optional parameters:
39
+ #
40
+ # logtype | String | The log type, as a string. log-types are typically of the form ITEM_TYPE.ACTION, where ITEM_TYPE is the type of item that was affected and ACTION is what happened to it. For example, message.queued.
41
+ # item_id | Fixnum | Unique id of item that was affected.
42
+ # operator_id | Fixnum | Unique id of operator that caused this log.
43
+ # limit | Fixnum | Used for pagination, number of log records to return
44
+ # start_key | Fixnum | Used for pagination, value of last_key from previous response
45
+ #
46
+ #
47
+ # last_key, log_items = VivialConnect::Log.find_by_time(start_time: "20170220T204352Z", end_time: "20170421T204352Z")
48
+ # => [ 7b226163...', [ #<VivialConnect::Log>, #<VivialConnect::Log>, #<VivialConnect::Log> ]]
49
+ #
50
+ #
51
+
52
+ class Log < Resource
53
+
54
+ def self.find_by_time(options = {}) #:nodoc:
55
+ uri = '/logs.json'
56
+ numbers_template = Addressable::Template.new("#{uri}{?query*}")
57
+ uri = numbers_template.expand(query: options).to_s
58
+ VivialConnect::Client.instance.make_request('GET', uri)
59
+ end
60
+
61
+ def self.find_aggregate_by_time(options = {}) #:nodoc:
62
+ uri = '/logs/aggregate.json'
63
+ numbers_template = Addressable::Template.new("#{uri}{?query*}")
64
+ uri = numbers_template.expand(query: options).to_s
65
+ VivialConnect::Client.instance.make_request('GET', uri)
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+
@@ -0,0 +1,222 @@
1
+ module VivialConnect
2
+ ##
3
+ #=== .all
4
+ #
5
+ #Returns an array containing ruby objects corresponding to all Message resources on your account
6
+ #
7
+ #
8
+ # Example usage:
9
+ #
10
+ #
11
+ # VivialConnect::Message.all
12
+ # => [#<VivialConnect::Message to_number="#", from_number="#", body="example message", account_id=1XXXX, date_created="2017-04-19T15:18:12-04:00", date_modified="2017-04-19T15:18:12-04:00", direction="outbound-api", error_code=nil, error_message=nil, id=17219, master_account_id=1XXXX, message_status_callback=nil, message_type="local_sms", num_media=0, num_segments=1, price=75, price_currency="USD", sent=nil, sms_configuration_id=nil, status="accepted">]
13
+ #
14
+ #
15
+ #=== .count
16
+ #
17
+ #Returns the amount of Messages sent from your account
18
+ #
19
+ # Example usage:
20
+ #
21
+ #
22
+ # VivialConnect::Message.count
23
+ # => 5072
24
+ #
25
+ #
26
+ ##
27
+ #=== .create(options={})
28
+ #
29
+ #Creates a record of the message and sends it to the `to_number`. This method is also aliased as VivialConnect::Message.send(options={})
30
+ #
31
+ #
32
+ # Required parameters:
33
+ #
34
+ #
35
+ # to_number | String | "+16125551212" <--NOTE: "+1" in front of the number.
36
+ # from_number | String | "+16125554444"
37
+ # body | String | "My test message"
38
+ #
39
+ #
40
+ # Optional parameter: for MMS
41
+ #
42
+ # media_urls | Array | ["www.yourhost.com/path/to/image"] <--NOTE: Array datatype is required, even if only passing one piece of media
43
+ #
44
+ #
45
+ # Example Usage
46
+ #
47
+ #
48
+ # SMS
49
+ #
50
+ # VivialConnect::Message.send(to_number: "+1##########", from_number: "+1##########", body: "example message")
51
+ # VivialConnect::Message.create(to_number: "+1##########", from_number: "+1##########", body: "example message")
52
+ # => #<VivialConnect::Message to_number="+1##########", from_number="+1##########", body="example message", account_id=1XXXX, date_created="2017-04-19T15:18:12-04:00", date_modified="2017-04-19T15:18:12-04:00", direction="outbound-api", error_code=nil, error_message=nil, id=17219, master_account_id=1XXXX, message_status_callback=nil, message_type="local_sms", num_media=0, num_segments=1, price=75, price_currency="USD", sent=nil, sms_configuration_id=nil, status="accepted">
53
+ #
54
+ #
55
+ # MMS
56
+ #
57
+ # VivialConnect::Message.send(to_number: "+1##########", from_number: "+1##########", body: "example mms", content_urls: ['www.yourhost/path/to/media'])
58
+ # VivialConnect::Message.create(to_number: "+1##########", from_number: "+1##########", body: "example mms", content_urls: ['www.yourhost/path/to/media'])
59
+ # => #<VivialConnect::Message account_id=1XXXXX, body="example mms", date_created="2017-04-19T11:18:11-04:00", date_modified="2017-04-19T11:18:34-04:00", direction="outbound-api", error_code=nil, error_message=nil, from_number="+1##########", id=6399, master_account_id=1XXXX message_status_callback=nil, message_type="local_mms", num_media=1, num_segments=1, price=100, price_currency="USD", sent="2017-04-19T11:18:16-04:00", sms_configuration_id=nil, status="delivered", to_number="+1##########">
60
+ #
61
+ #
62
+ #
63
+ #
64
+ #
65
+ ##
66
+ #=== .find(id)
67
+ #
68
+ #Returns the a Messsage object referenced by the `id` value.
69
+ #
70
+ # Required parameter:
71
+ #
72
+ # id | Fixnum | the id of the message you would like to retrieve
73
+ #
74
+ #
75
+ # Example usage:
76
+ #
77
+ #
78
+ # VivialConnect::Message.find(17219)
79
+ # => #<VivialConnect::Message to_number="+1##########", from_number="+1##########", body="example message", account_id=1XXXX, date_created="2017-04-19T15:18:12-04:00", date_modified="2017-04-19T15:18:12-04:00", direction="outbound-api", error_code=nil, error_message=nil, id=17219, master_account_id=1XXXX, message_status_callback=nil, message_type="local_sms", num_media=0, num_segments=1, price=75, price_currency="USD", sent=nil, sms_configuration_id=nil, status="accepted">
80
+ #
81
+ #
82
+ ##
83
+ #=== .find_each(start: 1, finish: nil, batch_size: 150)
84
+ #
85
+ #Iterates through all of the messages on your account in N sized batches beginning at the `start: value` and ending at the `finish: value`.
86
+ #
87
+ #
88
+ # When a block is given this method yields an individual Message object.
89
+ # Without a block, this method returns an Enumerator.
90
+ #
91
+ #
92
+ # By default, it will begin at the first message and end at the last message
93
+ #
94
+ #
95
+ # With default batch_size: 150, if you wanted to get your records from
96
+ # 150 to 300 you would start at 2 and finish at 2.
97
+ #
98
+ #
99
+ # Returns an Array of objects corresponding to the `start` and `finish` values. Default is all objects.
100
+ #
101
+ # Optional parameters:
102
+ #
103
+ # start | Fixnum | batch to start with
104
+ # finish | Fixnum | batch to end with
105
+ # batch_size | Fixnum | between 1..150
106
+ #
107
+ #
108
+ # Example usage:
109
+ #
110
+ #
111
+ # VivialConnect::Message.find_each {|message| puts message.body}
112
+ # example message
113
+ # => [#<VivialConnect::Message to_number="#", from_number="#", body="example message", account_id=1XXXX, date_created="2017-04-19T15:18:12-04:00", date_modified="2017-04-19T15:18:12-04:00", direction="outbound-api", error_code=nil, error_message=nil, id=17219, master_account_id=1XXXX, message_status_callback=nil, message_type="local_sms", num_media=0, num_segments=1, price=75, price_currency="USD", sent=nil, sms_configuration_id=nil, status="accepted">, ...]
114
+ #
115
+ #
116
+ #
117
+ #
118
+ ##
119
+ #=== .find_in_batches(start: 1, finish: nil, batch_size: 150)
120
+ #
121
+ #Iterates through all of the messages on your account in N sized batches beginning at the `start: value` and ending at the `finish: value`.
122
+ #
123
+ #
124
+ # When a block is given this method yields an array of batch_size resource objects.
125
+ # Without a block, it returns an Enumerator.
126
+ #
127
+ #
128
+ # By default, it will begin at the first message and end at the last message
129
+ #
130
+ #
131
+ # With default batch_size: 150, if you wanted to get your records from
132
+ # 150 to 300 you would start at 2 and finish at 2.
133
+ #
134
+ #
135
+ # Returns an Array of objects corresponding to the `start` and `finish` values. Default is all objects.
136
+ #
137
+ # Optional parameters:
138
+ #
139
+ # start | Fixnum | batch to start with
140
+ # finish | Fixnum | batch to end with
141
+ # batch_size | Fixnum | between 1..150
142
+ #
143
+ #
144
+ # Example usage:
145
+ #
146
+ #
147
+ # VivialConnect::Message.find_in_batches {|batch| do_something_with_an_array(batch)}
148
+ # => [#<VivialConnect::Message to_number="#", from_number="#", body="example message", account_id=1XXXX, date_created="2017-04-19T15:18:12-04:00", date_modified="2017-04-19T15:18:12-04:00", direction="outbound-api", error_code=nil, error_message=nil, id=17219, master_account_id=1XXXX, message_status_callback=nil, message_type="local_sms", num_media=0, num_segments=1, price=75, price_currency="USD", sent=nil, sms_configuration_id=nil, status="accepted">, ...]
149
+ #
150
+ #
151
+ #
152
+ #
153
+ ##
154
+ #=== .redact(id)
155
+ #
156
+ # Deletes the message body of the Message corresponding to the id provided.
157
+ #
158
+ # Example usage:
159
+ #
160
+ #
161
+ # VivialConnect::Message.redact(1)
162
+ # => #<VivialConnect::Message to_number="+1##########", from_number="+1##########", body="", account_id=1XXXX, date_created="2017-04-19T15:18:12-04:00", date_modified="2017-04-19T15:18:12-04:00", direction="outbound-api", error_code=nil, error_message=nil, id=17219, master_account_id=1XXXX, message_status_callback=nil, message_type="local_sms", num_media=0, num_segments=1, price=75, price_currency="USD", sent=nil, sms_configuration_id=nil, status="accepted">
163
+ #
164
+ #
165
+ ##
166
+ #=== \#save
167
+ #
168
+ #Creates a message and sends it.
169
+ #
170
+ #
171
+ # Example usage:
172
+ #
173
+ # message = VivialConnect::Message.new
174
+ # message.to_number = "+1##########"
175
+ # message.from_number = "+1##########"
176
+ # message.body = "Example message"
177
+ # message.save
178
+ # => #<VivialConnect::Message to_number="+1##########", from_number="+1##########", body="Example message", account_id=1XXXX, date_created="2017-04-19T16:18:12-04:00", date_modified="2017-04-19T16:18:12-04:00", direction="outbound-api", error_code=nil, error_message=nil, id=17220, master_account_id=1XXXX, message_status_callback=nil, message_type="local_sms", num_media=0, num_segments=1, price=75, price_currency="USD", sent=nil, sms_configuration_id=nil, status="accepted">
179
+ #
180
+ #
181
+ ##
182
+ #=== \#redact
183
+ #
184
+ #Deletes the message body on a Message object.
185
+ #
186
+ #
187
+ # Example usage:
188
+ #
189
+ #
190
+ # message.redact
191
+ # => #<VivialConnect::Message to_number="+1##########", from_number="+1##########", body="", account_id=1XXXX, date_created="2017-04-19T15:18:12-04:00", date_modified="2017-04-19T15:18:12-04:00", direction="outbound-api", error_code=nil, error_message=nil, id=17219, master_account_id=1XXXX, message_status_callback=nil, message_type="local_sms", num_media=0, num_segments=1, price=75, price_currency="USD", sent=nil, sms_configuration_id=nil, status="accepted">
192
+ #
193
+ #
194
+
195
+ class Message < Resource
196
+
197
+ singleton_class.send(:alias_method, :send, :create)
198
+
199
+ def self.redact(id) # :nodoc:
200
+ data = {}
201
+ data['message'] = {id: id, body: ""}
202
+ data = data.to_json
203
+ VivialConnect::Client.instance.make_request('PUT',"/messages/#{id}.json", data)
204
+ end
205
+
206
+
207
+ def redact # :nodoc:
208
+ raise VivialConnectClientError, "your message object has no id and therefore cannot be redacted" if self.id.nil?
209
+ id = self.id
210
+ data = {}
211
+ data['message'] = {id: id, body: ""}
212
+ data = data.to_json
213
+ VivialConnect::Client.instance.make_request('PUT',"/messages/#{id}.json", data)
214
+ end
215
+
216
+
217
+ end
218
+
219
+ end
220
+
221
+
222
+