burstsms 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +94 -63
- data/burstsms.gemspec +1 -1
- data/lib/burstsms/api.rb +1 -1
- data/lib/burstsms/lists_add_recipient.rb +2 -2
- data/lib/burstsms/lists_delete_recipient.rb +2 -2
- data/lib/burstsms/messages_add.rb +4 -3
- data/lib/burstsms/messages_multiple.rb +2 -2
- data/lib/burstsms/version.rb +1 -1
- data/spec/fixtures/api_requests/messages_add.txt +1 -1
- data/spec/fixtures/api_requests/messages_multiple.txt +1 -1
- metadata +14 -14
data/README.md
CHANGED
@@ -16,23 +16,19 @@ and run `bundle` from your shell.
|
|
16
16
|
|
17
17
|
Usage
|
18
18
|
-----
|
19
|
-
**Create an authenticated instance**
|
19
|
+
**Create an authenticated instance**
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
Responses from the API are converted into ruby objects with attributes you can access.
|
25
|
-
|
26
|
-
Available attributes for each method are listed in their description below.
|
27
|
-
|
28
|
-
Every method will return a `error` attribute if something goes wrong
|
21
|
+
```ruby
|
22
|
+
@burstsms = BurstSms::API.new('api_key', 'secret')
|
23
|
+
```
|
29
24
|
|
25
|
+
**Send a SMS** - [messages.multiple](http://burstsms.com/api-documentation/messages.multiple)
|
30
26
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
```ruby
|
28
|
+
@burstsms.send_message('caller_id', 'recipients', 'message')
|
29
|
+
|
30
|
+
Response attributes :result :total_recipients :total_recipients_queued :message_id :contact_list_addition
|
31
|
+
```
|
36
32
|
|
37
33
|
`caller_id` Can be a Number upto 15 digits or a alpha-numeric string upto 11 characters.
|
38
34
|
`recipient/s` A single mobile number or an array of mobile numbers for multiple recipients.
|
@@ -44,79 +40,114 @@ Every method will return a `error` attribute if something goes wrong
|
|
44
40
|
*__NOTE:__The gem handles conversion of mobile numbers to the format required by the API. Also duplicate and invalid numbers will be deleted from the array.*
|
45
41
|
__example__: you can pass in an array of numbers like `['+61 414 899 766', '0403 855 555', '0403-855-445']` and it will be converted to `['61414899766', '61403855555', '61403855445']`
|
46
42
|
|
43
|
+
**Responses**
|
44
|
+
Responses from the API are converted into ruby objects with attributes you can access.
|
45
|
+
|
46
|
+
Available attributes for each method are listed in their description below.
|
47
|
+
|
48
|
+
Every method will return a `error` attribute if something goes wrong
|
49
|
+
|
47
50
|
------
|
48
51
|
|
49
52
|
Additional Methods
|
50
53
|
------------------
|
51
54
|
|
52
|
-
**Send a SMS to an existing list** - [messages.add](http://burstsms.com/api-documentation/messages.add)
|
55
|
+
**Send a SMS to an existing list** - [messages.add](http://burstsms.com/api-documentation/messages.add)
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
@burstsms.add_message('caller_id', 'list_id', 'message')
|
59
|
+
|
60
|
+
#returns :total :time :result :message_id :list_id :message :cost :balance :charge_error
|
61
|
+
```
|
62
|
+
**Retrieve history of sent messages** - [messages.get](http://burstsms.com/api-documentation/messages.get)
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
@burstsms.get_messages() #takes optional arguments offset and limit(default is 50)
|
66
|
+
|
67
|
+
#returns :total :time :messages
|
68
|
+
#messages return :id :list_id :mobile_from :message :datetime_send :datetime_actioned :recipient_count :status :schedule
|
69
|
+
```
|
70
|
+
|
71
|
+
**Retrieve responses from a message** - [messages.responses](http://burstsms.com/api-documentation/messages.responses)
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
@burstsms.message_responses('message_id') #takes optional arguments offset and limit(default is 50)
|
75
|
+
|
76
|
+
#returns :total :time :replies
|
77
|
+
#replies return :firstname :lastname :mobile :message :datetime_entry_orig
|
78
|
+
```
|
79
|
+
|
80
|
+
**Retrieve Contact Lists** - [contact-lists.get](http://burstsms.com/api-documentation/contact-lists.get)
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
@burstsms.get_lists() #takes optional arguments offset and limit(default is 50)
|
53
84
|
|
54
|
-
|
55
|
-
|
56
|
-
|
85
|
+
#returns :total :time :lists
|
86
|
+
#lists return :id :name :recipient_count
|
87
|
+
```
|
57
88
|
|
58
|
-
**
|
89
|
+
**Add Contact List** - [contact-lists.add](http://burstsms.com/api-documentation/contact-lists.add)
|
59
90
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
**Retrieve responses from a message** - [messages.responses](http://burstsms.com/api-documentation/messages.responses)
|
91
|
+
```ruby
|
92
|
+
@burstsms.add_list('name of new list')
|
93
|
+
|
94
|
+
#returns :total :time :name :list_id :recipient_count
|
95
|
+
```
|
66
96
|
|
67
|
-
|
68
|
-
|
69
|
-
#returns :total :time :replies
|
70
|
-
#replies return :firstname :lastname :mobile :message :datetime_entry_orig
|
97
|
+
**Delete Contact List** - [contact-lists.delete](http://burstsms.com/api-documentation/contact-lists.delete)
|
71
98
|
|
72
|
-
|
99
|
+
```ruby
|
100
|
+
@burstsms.delete_list('list_id')
|
101
|
+
|
102
|
+
#returns :total :time :response
|
103
|
+
```
|
73
104
|
|
74
|
-
|
75
|
-
|
76
|
-
#returns :total :time :lists
|
77
|
-
#lists return :id :name :recipient_count
|
105
|
+
**Retrieve Contact List Recipients** - [contact-lists.get-recipients](http://burstsms.com/api-documentation/contact-lists.get-recipients)
|
78
106
|
|
79
|
-
|
107
|
+
```ruby
|
108
|
+
@burstsms.get_list_recipients('list_id') #takes optional arguments offset and limit(default is 50)
|
80
109
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
**Delete Contact List** - [contact-lists.delete](http://burstsms.com/api-documentation/contact-lists.delete)
|
110
|
+
#returns :total :time :recipients
|
111
|
+
#recipients return :firstname :lastname :mobile :datetime_entry :dest_country :bounce_count
|
112
|
+
```
|
86
113
|
|
87
|
-
|
88
|
-
|
89
|
-
#returns :total :time :response
|
90
|
-
|
91
|
-
**Retrieve Contact List Recipients** - [contact-lists.get-recipients](http://burstsms.com/api-documentation/contact-lists.get-recipients)
|
114
|
+
**Retrieve Contact List Unsubscribed** - [contact-lists.get-unsubscribed](http://burstsms.com/api-documentation/contact-lists.get-unsubscribed)
|
92
115
|
|
93
|
-
|
116
|
+
```ruby
|
117
|
+
@burstsms.get_list_unsubscribed('list_id') #takes optional arguments offset and limit(default is 50)
|
94
118
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
**Retrieve Contact List Unsubscribed** - [contact-lists.get-unsubscribed](http://burstsms.com/api-documentation/contact-lists.get-unsubscribed)
|
119
|
+
#returns :total :time :recipients
|
120
|
+
#recipients return :firstname :lastname :mobile :datetime_entry :dest_country :bounce_count
|
121
|
+
```
|
99
122
|
|
100
|
-
|
123
|
+
**Add Contact List Recipient** - [contact-lists.add-recipient](http://burstsms.com/api-documentation/contact-lists.add-recipient)
|
101
124
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
**Add Contact List Recipient** - [contact-lists.add-recipient](http://burstsms.com/api-documentation/contact-lists.add-recipient)
|
125
|
+
```ruby
|
126
|
+
@burstsms.add_list_recipient("list_id", "mobile_number", :firstname => 'Bob', :lastname => 'Smith') #name fields optional
|
106
127
|
|
107
|
-
|
128
|
+
#returns :total :time :result :list_id
|
129
|
+
#refer to Burst Sms docs for possible result values
|
130
|
+
```
|
108
131
|
|
109
|
-
|
110
|
-
#refer to Burst Sms docs for possible result values
|
111
|
-
|
112
|
-
**Delete Contact List Recipient** - [contact-lists.delete-recipient](http://burstsms.com/api-documentation/contact-lists.delete-recipient)
|
132
|
+
**Delete Contact List Recipient** - [contact-lists.delete-recipient](http://burstsms.com/api-documentation/contact-lists.delete-recipient)
|
113
133
|
|
114
|
-
|
134
|
+
```ruby
|
135
|
+
@burstsms.delete_list_recipient("list_id", "mobile_number")
|
115
136
|
|
116
|
-
|
117
|
-
|
137
|
+
#returns :total :time :result
|
138
|
+
#refer to Burst Sms docs for possible result values
|
139
|
+
```
|
118
140
|
|
119
141
|
------
|
142
|
+
|
143
|
+
Under the Hood
|
144
|
+
--------------
|
145
|
+
|
146
|
+
The `burstsms` gem uses:
|
147
|
+
|
148
|
+
- [UnhappyMapper](https://github.com/burtlo/happymapper) and [Nokogiri](http://nokogiri.org/) to handle the XML ugliness.
|
149
|
+
- [HTTParty](https://github.com/jnunemaker/httparty) for the HTTP interaction with the API.
|
150
|
+
|
120
151
|
**TODO**
|
121
152
|
|
122
153
|
- Complete 'contact-lists.add-multiple-recipients'
|
data/burstsms.gemspec
CHANGED
data/lib/burstsms/api.rb
CHANGED
@@ -9,8 +9,8 @@ module BurstSms
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def add_list_recipient_body(list_id, mobile, options={})
|
12
|
-
build_request("contact-lists.add-recipient", :
|
13
|
-
:
|
12
|
+
build_request("contact-lists.add-recipient", :mobile => mobile,
|
13
|
+
:list_id => list_id,
|
14
14
|
:firstname => (options.has_key?(:firstname) ? options[:firstname] : nil),
|
15
15
|
:lastname => (options.has_key?(:lastname) ? options[:lastname] : nil),
|
16
16
|
:mobile_dest_country => (options.has_key?(:mobile_dest_country) ? options[:mobile_dest_country] : nil)
|
@@ -9,8 +9,8 @@ module BurstSms
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def delete_list_recipient_body(list_id, mobile)
|
12
|
-
build_request("contact-lists.delete-recipient", :
|
13
|
-
:
|
12
|
+
build_request("contact-lists.delete-recipient", :mobile => mobile,
|
13
|
+
:list_id => list_id)
|
14
14
|
end
|
15
15
|
|
16
16
|
class Response
|
@@ -9,11 +9,12 @@ module BurstSms
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def add_message_body(from, list_id, message, options={})
|
12
|
-
build_request("messages.add", :
|
13
|
-
:
|
12
|
+
build_request("messages.add", :list_id => list_id,
|
13
|
+
:caller_id => check_valid_sender(from),
|
14
14
|
:message => encode_msg(message),
|
15
15
|
:sendtime => (options.has_key?(:sendtime) ? options[:sendtime] : nil),
|
16
|
-
:contact_list => (options.has_key?(:contact_list) ? options[:contact_list] : nil)
|
16
|
+
:contact_list => (options.has_key?(:contact_list) ? options[:contact_list] : nil),
|
17
|
+
)
|
17
18
|
end
|
18
19
|
|
19
20
|
class Response
|
@@ -9,8 +9,8 @@ module BurstSms
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def send_message_body(from, recipients, message, options={})
|
12
|
-
build_request("messages.multiple", :
|
13
|
-
:
|
12
|
+
build_request("messages.multiple", :mobile => sanitize_numbers(recipients),
|
13
|
+
:caller_id => check_valid_sender(from),
|
14
14
|
:message => encode_msg(message),
|
15
15
|
:sendtime => (options.has_key?(:sendtime) ? options[:sendtime] : nil),
|
16
16
|
:contact_list => (options.has_key?(:contact_list) ? options[:contact_list] : nil))
|
data/lib/burstsms/version.rb
CHANGED
@@ -5,8 +5,8 @@ request=<?xml version="1.0"?>
|
|
5
5
|
<secret>x</secret>
|
6
6
|
<method>messages.add</method>
|
7
7
|
<params>
|
8
|
+
<list_id>1075</list_id>
|
8
9
|
<caller_id>6147779990</caller_id>
|
9
10
|
<message>sms%20txt%0A%20of%20words%20and%20such%3A%2F</message>
|
10
|
-
<list_id>1075</list_id>
|
11
11
|
</params>
|
12
12
|
</request>
|
@@ -5,8 +5,8 @@ request=<?xml version="1.0"?>
|
|
5
5
|
<secret>x</secret>
|
6
6
|
<method>messages.multiple</method>
|
7
7
|
<params>
|
8
|
-
<caller_id>6147779990</caller_id>
|
9
8
|
<mobile>61490900900,61490900910,61414899766,61403855445,61487000777</mobile>
|
9
|
+
<caller_id>6147779990</caller_id>
|
10
10
|
<message>sms%20txt%0A%20of%20words%20and%20such%3A%2F</message>
|
11
11
|
</params>
|
12
12
|
</request>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: burstsms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-24 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: unhappymapper
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153740780 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.4.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153740780
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: httparty
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153740260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153740260
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &2153739620 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '2.6'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2153739620
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: webmock
|
49
|
-
requirement: &
|
49
|
+
requirement: &2153739060 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.7.10
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2153739060
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &2153738680 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2153738680
|
69
69
|
description:
|
70
70
|
email:
|
71
71
|
- david@madeindata.com
|