osm 1.2.18.dev.4 → 1.2.18.dev.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +6 -1
- data/lib/osm/section.rb +2 -17
- data/lib/osm/sms.rb +54 -19
- data/spec/osm/section_spec.rb +0 -12
- data/spec/osm/sms_spec.rb +61 -64
- data/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTVmYTI0ZmYzMWMyNmQ0NDBmY2VhZGQ4MDJjYTZiZTBmYjdiYjU0Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDRjN2MxMjlkYjc4OWYyYmE4N2VkOThhMDM0N2QyYjI1MzUxZjM0ZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTc0MDVhMjIxZjQ0M2ZhNzIxOWQ2M2NjNTk5MmQyY2JhMmE2NGE3ZWExY2Vm
|
10
|
+
YzI0ZDkxMTZhOWNhOWQ0MzgwM2UyNTQ3YWU0ZDk2MWFlNjllMzNkZDQwODJi
|
11
|
+
MDIyZDEwMDM4NjFhODQ1NWNmYjI2OTJkMzY2N2ZjZDFkZGZkOTc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWZiZDdlYzViMjBhYzc1NjZjZGE2ZjhjMjBjMmYzZDdiNGM3ZmE5NTkzYmE2
|
14
|
+
OGNjYzhlMWI2YjdlOGIwN2RkODRiZjJlNjliMmVkNWZhMmM4ZGRlYWFiMDFi
|
15
|
+
ZTYwYTQxYWY0NTM1MmY4YWUzMGZjYWI3MWUwY2M1MjIxNDQ5NTg=
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
## Version 1.2.18
|
2
2
|
|
3
3
|
* THIS IS A DEVELOPMENT VERSION OF THIS RELEASE. IT EXISTS ONLY SO YOU CAN PLAY WITH THE NEW STRUCTIRE OF MEMBERS YOU'LL GET WHEN OSM CHANGES. WRITING CHANGES BACK TO OSM HAS NOT YET BEEN UPDATED.
|
4
|
-
* Osm::Section - removal of column_names, fields, intouch_fields, mobile_fields attributes
|
4
|
+
* Osm::Section - removal of column_names, fields, intouch_fields, mobile_fields and sms_* attributes
|
5
5
|
* Osm::Member - lots of changes to reflect OSM's new structure for member's details (main ones listed below):
|
6
6
|
* Removal of type attribute (I never could work out what it represented)
|
7
7
|
* Removal of data attributes except:
|
@@ -32,6 +32,11 @@
|
|
32
32
|
* all_phones, enabled_phones
|
33
33
|
* Validation changes:
|
34
34
|
* age should now be in the format 'yy / mm' not 'yy/mm'
|
35
|
+
* Osm::Sms:
|
36
|
+
* send_sms method losses mobile_numbers argumant (OSM now sends to all enabled numbers for all contacts for the member)
|
37
|
+
* send_sms method now just returns a boolean to indicate success/failure
|
38
|
+
* Addition of remaining_credits(api, section, options={}) method
|
39
|
+
* Addition of number_selected(api, section, members, options={}) method to tell how many numbers a message would be sent to
|
35
40
|
|
36
41
|
## Version 1.2.17
|
37
42
|
|
data/lib/osm/section.rb
CHANGED
@@ -61,12 +61,7 @@ module Osm
|
|
61
61
|
# @return [Fixnum] How many days to leave between payment reminder emails
|
62
62
|
# @!attribute [rw] myscout_details_email_changes_to
|
63
63
|
# @return [String] email address to send changes to personal details made through My.SCOUT to
|
64
|
-
|
65
|
-
# @return [Boolean] Whether the section has sent their test SMS message
|
66
|
-
# @!attribute [rw] sms_messages_sent
|
67
|
-
# @return [Fixnum] How many SMS messages have been sent by the section
|
68
|
-
# @!attribute [rw] sms_messages_remaining
|
69
|
-
# @return [Fixnum] How many SMS messages the section can send before needing to topup
|
64
|
+
|
70
65
|
|
71
66
|
attribute :id, :type => Integer
|
72
67
|
attribute :name, :type => String
|
@@ -98,9 +93,6 @@ module Osm
|
|
98
93
|
attribute :myscout_payment_reminder_count, :type => Integer
|
99
94
|
attribute :myscout_payment_reminder_frequency, :type => Integer
|
100
95
|
attribute :myscout_details_email_changes_to, :type => String, :default => ''
|
101
|
-
attribute :sms_sent_test, :type => Boolean, :default => false
|
102
|
-
attribute :sms_messages_sent, :type => Integer, :default => 0
|
103
|
-
attribute :sms_messages_remaining, :type => Integer, :default => 0
|
104
96
|
|
105
97
|
if ActiveModel::VERSION::MAJOR < 4
|
106
98
|
attr_accessible :id, :name, :group_id, :group_name, :subscription_level, :subscription_expires,
|
@@ -112,8 +104,7 @@ module Osm
|
|
112
104
|
:myscout_badges_partial, :myscout_programme_summary, :myscout_programme_times,
|
113
105
|
:myscout_programme_show, :myscout_event_reminder_count,
|
114
106
|
:myscout_event_reminder_frequency, :myscout_payment_reminder_count,
|
115
|
-
:myscout_payment_reminder_frequency, :myscout_details_email_changes_to
|
116
|
-
:sms_sent_test, :sms_messages_sent, :sms_messages_remaining
|
107
|
+
:myscout_payment_reminder_frequency, :myscout_details_email_changes_to
|
117
108
|
end
|
118
109
|
|
119
110
|
validates_numericality_of :id, :only_integer=>true, :greater_than=>0, :allow_nil => true
|
@@ -122,8 +113,6 @@ module Osm
|
|
122
113
|
validates_numericality_of :myscout_event_reminder_frequency, :only_integer=>true, :greater_than_or_equal_to=>-1
|
123
114
|
validates_numericality_of :myscout_payment_reminder_count, :only_integer=>true, :greater_than_or_equal_to=>-1
|
124
115
|
validates_numericality_of :myscout_payment_reminder_frequency, :only_integer=>true, :greater_than_or_equal_to=>-1
|
125
|
-
validates_numericality_of :sms_messages_sent, :only_integer=>true, :greater_than_or_equal_to=>0
|
126
|
-
validates_numericality_of :sms_messages_remaining, :only_integer=>true, :greater_than_or_equal_to=>0
|
127
116
|
validates_presence_of :name
|
128
117
|
validates_presence_of :group_name
|
129
118
|
validates_presence_of :subscription_level
|
@@ -142,7 +131,6 @@ module Osm
|
|
142
131
|
validates_inclusion_of :myscout_programme_summary, :in => [true, false]
|
143
132
|
validates_inclusion_of :myscout_programme_times, :in => [true, false]
|
144
133
|
validates_inclusion_of :myscout_programme_show, :in => [-2, -1, 0, 5, 10, 15, 20]
|
145
|
-
validates_inclusion_of :sms_sent_test, :in => [true, false]
|
146
134
|
|
147
135
|
validates :myscout_emails, :hash => {:key_in => [:email1, :email2, :email3, :email4], :value_in => [true, false]}
|
148
136
|
validates :flexi_records, :array_of => {:item_type => Osm::FlexiRecord, :item_valid => true}
|
@@ -227,9 +215,6 @@ module Osm
|
|
227
215
|
:myscout_payment_reminder_count => myscout_data['paymentRemindCount'].to_i,
|
228
216
|
:myscout_payment_reminder_frequency => myscout_data['paymentRemindFrequency'].to_i,
|
229
217
|
:myscout_details_email_changes_to => myscout_data['contactNotificationEmail'],
|
230
|
-
:sms_sent_test => section_data['hasSentTestSMS'],
|
231
|
-
:sms_messages_sent => section_data['sms_sent'],
|
232
|
-
:sms_messages_remaining => section_data['sms_remaining'],
|
233
218
|
)
|
234
219
|
|
235
220
|
result.push section
|
data/lib/osm/sms.rb
CHANGED
@@ -2,39 +2,75 @@ module Osm
|
|
2
2
|
|
3
3
|
class Sms
|
4
4
|
|
5
|
-
#
|
5
|
+
# Send an SMS to some members on their enabled numbers
|
6
6
|
# @param [Osm::Api] api The api to use to make the request
|
7
7
|
# @param [Osm::Section, Fixnum, #to_i] section The section (or its ID) to send the message to
|
8
8
|
# @param [Array<Osm::Member, Fixnum, #to_i>, Osm::Member, Fixnum, #to_i] members The members (or their IDs) to send the message to
|
9
|
-
# @param [Symbol, String] mobile_numbers Wheather to send the message to all numbers for a member (:all) or just the first mobile one (:first) or a selection (e.g. "12", "24" etc.)
|
10
9
|
# @param [String, #to_s] source_address The number to claim the message is from
|
11
10
|
# @param [String, #to_s] message The text of the message to send
|
12
|
-
# @return [
|
13
|
-
|
14
|
-
|
15
|
-
Osm::Model.require_access_to_section(api, section)
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
# @return [Boolean] whether the messages were sent
|
12
|
+
# @raise [Osm::Error] If the section doesn't have enough credits to send the message
|
13
|
+
def self.send_sms(api, section, members, source_address, message)
|
14
|
+
Osm::Model.require_access_to_section(api, section)
|
15
|
+
raise Osm::Error, 'You do not have enough credits to send that message.' if number_selected(api, section, members) > remaining_credits(api, section)
|
16
|
+
|
17
|
+
members = [*members]
|
18
|
+
data = api.perform_query("ext/members/sms/?action=sendText§ionid=#{section.to_i}", {
|
19
19
|
'msg' => message,
|
20
|
-
'scouts' => [*members].join(','),
|
20
|
+
'scouts' => [*members.map{ |m| m.to_i }].join(','),
|
21
21
|
'source' => source_address,
|
22
|
-
'type' =>
|
23
|
-
'scheduled' => 'now',
|
22
|
+
'type' => '',
|
24
23
|
})
|
25
24
|
|
26
|
-
data.
|
27
|
-
|
28
|
-
|
29
|
-
k = 'sent' if k.eql?('sent_to')
|
30
|
-
[k.to_sym, v]
|
25
|
+
if data.is_a?(Hash) && data['result']
|
26
|
+
Osm::Model.cache_write(api, ['sms_credits', section.to_i], data['msg'].match(/\A[^\d]*(\d+)[^\d]*\Z/)[1])
|
27
|
+
return true
|
31
28
|
end
|
32
|
-
return
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
|
32
|
+
# Get the number of remaining SMS credits for a section
|
33
|
+
# @param [Osm::Api] api The api to use to make the request
|
34
|
+
# @param [Osm::Section, Fixnum, #to_i] section The section (or its ID) to send the message to
|
35
|
+
# @!macro options_get
|
36
|
+
# @return [Fixnum] the number of remaining SMS credits for the section
|
37
|
+
def self.remaining_credits(api, section, options={})
|
38
|
+
Osm::Model.require_access_to_section(api, section)
|
39
|
+
cache_key = ['sms_credits', section.to_i]
|
40
|
+
|
41
|
+
if !options[:no_cache] && Osm::Model.cache_exist?(api, cache_key)
|
42
|
+
return Osm::Model.cache_read(api, cache_key)
|
43
|
+
end
|
44
|
+
|
45
|
+
data = api.perform_query("ext/members/sms/?action=getNumbers§ionid=#{section.to_i}&type=", {
|
46
|
+
'scouts' => '0'
|
47
|
+
})
|
48
|
+
data = data['sms_remaining']
|
49
|
+
|
50
|
+
Osm::Model.cache_write(api, cache_key, data)
|
51
|
+
return data
|
33
52
|
end
|
34
53
|
|
54
|
+
# Get the number of SMS credits which will be used sending a message to the passed members
|
55
|
+
# @param [Osm::Api] api The api to use to make the request
|
56
|
+
# @param [Osm::Section, Fixnum, #to_i] section The section (or its ID) to send the message to
|
57
|
+
# @param [Array<Osm::Member, Fixnum, #to_i>, Osm::Member, Fixnum, #to_i] members The members (or their IDs) to send the message to
|
58
|
+
# @return [Fixnum] the number of SMS credits which will be used
|
59
|
+
def self.number_selected(api, section, members)
|
60
|
+
Osm::Model.require_access_to_section(api, section)
|
35
61
|
|
62
|
+
members = [*members]
|
63
|
+
data = api.perform_query("ext/members/sms/?action=getNumbers§ionid=#{section.to_i}&type=", {
|
64
|
+
'scouts' => [*members.map{ |m| m.to_i }].join(',')
|
65
|
+
})
|
66
|
+
|
67
|
+
Osm::Model.cache_write(api, ['sms_credits', section.to_i], data['sms_remaining'])
|
68
|
+
return data['numbers']
|
69
|
+
end
|
36
70
|
|
37
71
|
class DeliveryReport < Osm::Model
|
72
|
+
VALID_STATUSES = [:sent, :not_sent, :delivered, :not_delivered, :invalid_destination_address, :invalid_source_address, :invalid_message_format, :route_not_available, :not_allowed]
|
73
|
+
|
38
74
|
# @!attribute [rw] sms_id
|
39
75
|
# @return [Fixnum] the id of the SMS
|
40
76
|
# @!attribute [rw] user_id
|
@@ -92,7 +128,6 @@ module Osm
|
|
92
128
|
validates_presence_of :message
|
93
129
|
validates_presence_of :scheduled
|
94
130
|
validates_presence_of :last_updated
|
95
|
-
VALID_STATUSES = [:sent, :not_sent, :delivered, :not_delivered, :invalid_destination_address, :invalid_source_address, :invalid_message_format, :route_not_available, :not_allowed]
|
96
131
|
validates_inclusion_of :status, :in => VALID_STATUSES
|
97
132
|
|
98
133
|
|
data/spec/osm/section_spec.rb
CHANGED
@@ -38,9 +38,6 @@ describe "Section" do
|
|
38
38
|
:myscout_payment_reminder_frequency => 7,
|
39
39
|
:myscout_details => true,
|
40
40
|
:myscout_details_email_changes_to => 'notify-changes-to@example.com',
|
41
|
-
:sms_sent_test => true,
|
42
|
-
:sms_messages_sent => 8,
|
43
|
-
:sms_messages_remaining => 9,
|
44
41
|
}
|
45
42
|
end
|
46
43
|
|
@@ -78,9 +75,6 @@ describe "Section" do
|
|
78
75
|
section.myscout_payment_reminder_frequency.should == 7
|
79
76
|
section.myscout_details.should == true
|
80
77
|
section.myscout_details_email_changes_to.should == 'notify-changes-to@example.com'
|
81
|
-
section.sms_sent_test.should == true
|
82
|
-
section.sms_messages_sent.should == 8
|
83
|
-
section.sms_messages_remaining.should == 9
|
84
78
|
section.valid?.should == true
|
85
79
|
end
|
86
80
|
|
@@ -96,9 +90,6 @@ describe "Section" do
|
|
96
90
|
section.myscout_email_address_copy.should == ''
|
97
91
|
section.myscout_details_email_changes_to.should == ''
|
98
92
|
section.myscout_programme_show.should == 0
|
99
|
-
section.sms_sent_test.should == false
|
100
|
-
section.sms_messages_sent.should == 0
|
101
|
-
section.sms_messages_remaining.should == 0
|
102
93
|
end
|
103
94
|
|
104
95
|
|
@@ -150,9 +141,6 @@ describe "Section" do
|
|
150
141
|
section.myscout_payment_reminder_frequency.should == 7
|
151
142
|
section.myscout_details.should == true
|
152
143
|
section.myscout_details_email_changes_to.should == 'notify-changes-to@example.com'
|
153
|
-
section.sms_sent_test.should == true
|
154
|
-
section.sms_messages_remaining.should == 8
|
155
|
-
section.sms_messages_sent.should == 9
|
156
144
|
section.valid?.should == true
|
157
145
|
end
|
158
146
|
|
data/spec/osm/sms_spec.rb
CHANGED
@@ -5,124 +5,121 @@ describe "SMS" do
|
|
5
5
|
|
6
6
|
describe "Send an SMS" do
|
7
7
|
|
8
|
-
it "
|
9
|
-
|
8
|
+
it "One person" do
|
9
|
+
Osm::Sms.stub(:number_selected) { 3 }
|
10
|
+
Osm::Sms.stub(:remaining_credits) { 3 }
|
11
|
+
|
12
|
+
HTTParty.should_receive(:post).with('https://www.onlinescoutmanager.co.uk/ext/members/sms/?action=sendText§ionid=1', {:body => {
|
10
13
|
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
11
14
|
'token' => @CONFIGURATION[:api][:osm][:token],
|
12
15
|
'userid' => 'user_id',
|
13
16
|
'secret' => 'secret',
|
14
17
|
'msg' => 'Test message.',
|
15
|
-
'scouts' => '
|
18
|
+
'scouts' => '4',
|
16
19
|
'source' => '441234567890',
|
17
|
-
'type' =>
|
18
|
-
|
19
|
-
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>{'result'=>true,'sent'=>2,'message'=>'Success','debug'=>nil,'config'=>{}}.to_json}) }
|
20
|
+
'type' => '',
|
21
|
+
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>{"result" => true, "msg" => "Message sent - you have <b>131<\/b> credits left.", "config" => {}}.to_json}) }
|
20
22
|
|
21
23
|
result = Osm::Sms.send_sms(
|
22
24
|
@api,
|
23
25
|
1, # Section
|
24
|
-
|
25
|
-
:first,
|
26
|
+
4, # Members
|
26
27
|
'441234567890', # Source address
|
27
28
|
'Test message.' # Message text
|
28
29
|
)
|
29
30
|
|
30
|
-
result.should ==
|
31
|
-
:result => true,
|
32
|
-
:sent => 2,
|
33
|
-
:message => 'Success'
|
34
|
-
}
|
31
|
+
result.should == true
|
35
32
|
end
|
36
33
|
|
37
|
-
it "
|
38
|
-
|
34
|
+
it "Several people" do
|
35
|
+
Osm::Sms.stub(:number_selected) { 3 }
|
36
|
+
Osm::Sms.stub(:remaining_credits) { 3 }
|
37
|
+
|
38
|
+
HTTParty.should_receive(:post).with('https://www.onlinescoutmanager.co.uk/ext/members/sms/?action=sendText§ionid=1', {:body => {
|
39
39
|
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
40
40
|
'token' => @CONFIGURATION[:api][:osm][:token],
|
41
41
|
'userid' => 'user_id',
|
42
42
|
'secret' => 'secret',
|
43
|
-
'msg' => '
|
43
|
+
'msg' => 'This is a test message.',
|
44
44
|
'scouts' => '2,3',
|
45
45
|
'source' => '441234567890',
|
46
|
-
'type' =>
|
47
|
-
|
48
|
-
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>{'result'=>true,'sent'=>2,'message'=>'Success','debug'=>nil,'config'=>{}}.to_json}) }
|
46
|
+
'type' => '',
|
47
|
+
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>{"result" => true, "msg" => "Message sent - you have <b>95<\/b> credits left.", "config" => {}}.to_json}) }
|
49
48
|
|
50
49
|
result = Osm::Sms.send_sms(
|
51
50
|
@api,
|
52
51
|
1, # Section
|
53
52
|
[2, 3], # Members
|
54
|
-
:all,
|
55
53
|
'441234567890', # Source address
|
56
|
-
'
|
54
|
+
'This is a test message.' # Message text
|
57
55
|
)
|
58
56
|
|
59
|
-
result.should ==
|
60
|
-
:result => true,
|
61
|
-
:sent => 2,
|
62
|
-
:message => 'Success'
|
63
|
-
}
|
57
|
+
result.should == true
|
64
58
|
end
|
65
59
|
|
66
|
-
it "
|
67
|
-
|
60
|
+
it "Failed" do
|
61
|
+
Osm::Sms.stub(:number_selected) { 3 }
|
62
|
+
Osm::Sms.stub(:remaining_credits) { 3 }
|
63
|
+
|
64
|
+
HTTParty.should_receive(:post).with('https://www.onlinescoutmanager.co.uk/ext/members/sms/?action=sendText§ionid=1', {:body => {
|
68
65
|
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
69
66
|
'token' => @CONFIGURATION[:api][:osm][:token],
|
70
67
|
'userid' => 'user_id',
|
71
68
|
'secret' => 'secret',
|
72
69
|
'msg' => 'Test message.',
|
73
|
-
'scouts' => '
|
70
|
+
'scouts' => '4',
|
74
71
|
'source' => '441234567890',
|
75
|
-
'type' => '
|
76
|
-
|
77
|
-
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>{'result'=>true,'sent'=>2,'message'=>'Success','debug'=>nil,'config'=>{}}.to_json}) }
|
72
|
+
'type' => '',
|
73
|
+
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>{"result" => false,"config" => {}}.to_json}) }
|
78
74
|
|
79
75
|
result = Osm::Sms.send_sms(
|
80
76
|
@api,
|
81
77
|
1, # Section
|
82
|
-
[
|
83
|
-
'23',
|
78
|
+
[4], # Members
|
84
79
|
'441234567890', # Source address
|
85
80
|
'Test message.' # Message text
|
86
81
|
)
|
87
82
|
|
88
|
-
result.should ==
|
89
|
-
:result => true,
|
90
|
-
:sent => 2,
|
91
|
-
:message => 'Success'
|
92
|
-
}
|
83
|
+
result.should == false
|
93
84
|
end
|
94
85
|
|
95
|
-
it "
|
96
|
-
|
97
|
-
|
98
|
-
'token' => @CONFIGURATION[:api][:osm][:token],
|
99
|
-
'userid' => 'user_id',
|
100
|
-
'secret' => 'secret',
|
101
|
-
'msg' => 'Test message.',
|
102
|
-
'scouts' => '2,3',
|
103
|
-
'source' => '441234567890',
|
104
|
-
'type' => '14',
|
105
|
-
'scheduled' => 'now',
|
106
|
-
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>{'result'=>true,'sent'=>2,'message'=>'Success','debug'=>nil,'config'=>{}}.to_json}) }
|
86
|
+
it "Raises error if not enough credits" do
|
87
|
+
Osm::Sms.stub(:number_selected) { 3 }
|
88
|
+
Osm::Sms.stub(:remaining_credits) { 2 }
|
107
89
|
|
108
|
-
|
109
|
-
@api,
|
110
|
-
1, # Section
|
111
|
-
[2, 3], # Members
|
112
|
-
'14',
|
113
|
-
'441234567890', # Source address
|
114
|
-
'Test message.' # Message text
|
115
|
-
)
|
90
|
+
HTTParty.should_not_receive(:post)
|
116
91
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
:message => 'Success'
|
121
|
-
}
|
92
|
+
expect {
|
93
|
+
Osm::Sms.send_sms(@api, 1, [2, 3], '441234567890', 'Test message.')
|
94
|
+
}.to raise_error(Osm::Error, 'You do not have enough credits to send that message.')
|
122
95
|
end
|
123
96
|
|
124
97
|
end
|
125
98
|
|
99
|
+
it "Gets remaining credits" do
|
100
|
+
HTTParty.should_receive(:post).with('https://www.onlinescoutmanager.co.uk/ext/members/sms/?action=getNumbers§ionid=4&type=', {:body => {
|
101
|
+
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
102
|
+
'token' => @CONFIGURATION[:api][:osm][:token],
|
103
|
+
'userid' => 'user_id',
|
104
|
+
'secret' => 'secret',
|
105
|
+
'scouts' => '0',
|
106
|
+
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"members":0,"numbers":0,"sms_remaining":5}'}) }
|
107
|
+
|
108
|
+
Osm::Sms.remaining_credits(@api, 4).should == 5
|
109
|
+
end
|
110
|
+
|
111
|
+
it "Gets selected numbers" do
|
112
|
+
HTTParty.should_receive(:post).with('https://www.onlinescoutmanager.co.uk/ext/members/sms/?action=getNumbers§ionid=4&type=', {:body => {
|
113
|
+
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
114
|
+
'token' => @CONFIGURATION[:api][:osm][:token],
|
115
|
+
'userid' => 'user_id',
|
116
|
+
'secret' => 'secret',
|
117
|
+
'scouts' => '12,56',
|
118
|
+
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"members":2,"numbers":3,"sms_remaining":5}'}) }
|
119
|
+
|
120
|
+
Osm::Sms.number_selected(@api, 4, [12, 56]).should == 3
|
121
|
+
end
|
122
|
+
|
126
123
|
|
127
124
|
describe "Delivery Report" do
|
128
125
|
|
data/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.18.dev.
|
4
|
+
version: 1.2.18.dev.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Gauld
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|