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 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
- @burstsms = BurstSms::API.new('api_key', 'secret')
22
-
23
- **Responses**
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
- **Send a SMS** - [messages.multiple](http://burstsms.com/api-documentation/messages.multiple)
32
-
33
- @burstsms.send_message('caller_id', 'recipients', 'message')
34
-
35
- Response attributes :result :total_recipients :total_recipients_queued :message_id :contact_list_addition
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
- @burstsms.add_message('caller_id', 'list_id', 'message')
55
-
56
- #returns :total :time :result :message_id :list_id :message :cost :balance :charge_error
85
+ #returns :total :time :lists
86
+ #lists return :id :name :recipient_count
87
+ ```
57
88
 
58
- **Retrieve history of sent messages** - [messages.get](http://burstsms.com/api-documentation/messages.get)
89
+ **Add Contact List** - [contact-lists.add](http://burstsms.com/api-documentation/contact-lists.add)
59
90
 
60
- @burstsms.get_messages() #takes optional arguments offset and limit(default is 50)
61
-
62
- #returns :total :time :messages
63
- #messages return :id :list_id :mobile_from :message :datetime_send :datetime_actioned :recipient_count :status :schedule
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
- @burstsms.message_responses('message_id') #takes optional arguments offset and limit(default is 50)
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
- **Retrieve Contact Lists** - [contact-lists.get](http://burstsms.com/api-documentation/contact-lists.get)
99
+ ```ruby
100
+ @burstsms.delete_list('list_id')
101
+
102
+ #returns :total :time :response
103
+ ```
73
104
 
74
- @burstsms.get_lists() #takes optional arguments offset and limit(default is 50)
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
- **Add Contact List** - [contact-lists.add](http://burstsms.com/api-documentation/contact-lists.add)
107
+ ```ruby
108
+ @burstsms.get_list_recipients('list_id') #takes optional arguments offset and limit(default is 50)
80
109
 
81
- @burstsms.add_list('name of new list')
82
-
83
- #returns :total :time :name :list_id :recipient_count
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
- @burstsms.delete_list('list_id')
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
- @burstsms.get_list_recipients('list_id') #takes optional arguments offset and limit(default is 50)
116
+ ```ruby
117
+ @burstsms.get_list_unsubscribed('list_id') #takes optional arguments offset and limit(default is 50)
94
118
 
95
- #returns :total :time :recipients
96
- #recipients return :firstname :lastname :mobile :datetime_entry :dest_country :bounce_count
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
- @burstsms.get_list_unsubscribed('list_id') #takes optional arguments offset and limit(default is 50)
123
+ **Add Contact List Recipient** - [contact-lists.add-recipient](http://burstsms.com/api-documentation/contact-lists.add-recipient)
101
124
 
102
- #returns :total :time :recipients
103
- #recipients return :firstname :lastname :mobile :datetime_entry :dest_country :bounce_count
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
- @burstsms.add_list_recipient("list_id", "mobile_number", :firstname => 'Bob', :lastname => 'Smith') #name fields optional
128
+ #returns :total :time :result :list_id
129
+ #refer to Burst Sms docs for possible result values
130
+ ```
108
131
 
109
- #returns :total :time :result :list_id
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
- @burstsms.delete_list_recipient("list_id", "mobile_number")
134
+ ```ruby
135
+ @burstsms.delete_list_recipient("list_id", "mobile_number")
115
136
 
116
- #returns :total :time :result
117
- #refer to Burst Sms docs for possible result values
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'
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.require_paths = ["lib"]
18
18
 
19
19
 
20
- s.add_dependency "unhappymapper"
20
+ s.add_dependency "unhappymapper", "~> 0.4.4"
21
21
  s.add_dependency "httparty"
22
22
 
23
23
  s.add_development_dependency "rspec", "~> 2.6"
@@ -25,7 +25,7 @@ module BurstSms
25
25
  element :version, Float
26
26
  element :key, String
27
27
  element :secret, String
28
- element :api_method, String, :tag => 'method_'
28
+ element :api_method, String, :tag => 'method'
29
29
 
30
30
  has_one :params, String
31
31
 
@@ -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", :list_id => list_id,
13
- :mobile => mobile,
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", :list_id => list_id,
13
- :mobile => mobile)
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", :caller_id => check_valid_sender(from),
13
- :list_id => list_id,
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", :caller_id => check_valid_sender(from),
13
- :mobile => sanitize_numbers(recipients),
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))
@@ -1,3 +1,3 @@
1
1
  module BurstSms
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -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.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-20 00:00:00.000000000Z
12
+ date: 2012-02-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: unhappymapper
16
- requirement: &2152912720 !ruby/object:Gem::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: '0'
21
+ version: 0.4.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152912720
24
+ version_requirements: *2153740780
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: httparty
27
- requirement: &2152912300 !ruby/object:Gem::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: *2152912300
35
+ version_requirements: *2153740260
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2152911800 !ruby/object:Gem::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: *2152911800
46
+ version_requirements: *2153739620
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: webmock
49
- requirement: &2152911300 !ruby/object:Gem::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: *2152911300
57
+ version_requirements: *2153739060
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &2152910920 !ruby/object:Gem::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: *2152910920
68
+ version_requirements: *2153738680
69
69
  description:
70
70
  email:
71
71
  - david@madeindata.com