paycall-sms 0.1.0 → 0.1.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.
- checksums.yaml +8 -8
- data/VERSION +1 -1
- data/lib/pay_call_sms/delivery_notification_parser.rb +11 -1
- data/lib/pay_call_sms/incoming_message_parser.rb +2 -1
- data/lib/pay_call_sms/sms_sender.rb +4 -1
- data/paycall-sms.gemspec +3 -3
- data/spec/pay_call_sms/delivery_notifications_parser_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDRlNTQ3YmI4YjU1MzcwNTQ5Mjg2OTllNmQ2Njg1MjcwNGViNWU1OQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWQ5MGY3YzkxOTA5OTkyMjY3OWU3N2Y2NWJjYzJiZjM4NGY1ZjI4ZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Zjg3NDZmMjU3MWY3YTllYjY0ODA5M2RmOGFmZDNlMWRhYjE3MjczN2VjOGY5
|
10
|
+
YzliOWMzMDAxNWMxMDBiMTEwYzk0ZmIxYWNkNTZmM2EyMTNhYjRlZGZmZGE1
|
11
|
+
ZmU0NDgyODI2ZWY4MzM3NGZiMzg3NjM5OGY0MGZhOGZlZjJlOTI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTc3Y2IwNDU1ZTkwNTY3MDFhOGRmNjY1MDM4MTMwYmNlYzIwZThkNDc2YjAz
|
14
|
+
YWE5MzNhYWUxYTY5NTYxMjg1OWUyMTBmYjQ5YTdkNmJhOGVkMjczZWJhMjU0
|
15
|
+
MDI2ZDIxOGU1MDE5MmFhYjIwNWFlOGJlMTFiMTI4M2QwMDViYjc=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -13,6 +13,7 @@ module PayCallSms
|
|
13
13
|
# params will look something like the following:
|
14
14
|
# {"PhoneNumber"=>"972545290862", "CustomerMessageId"=>"34", "Status"=>"inprogress", "dateTime"=>"20-11-2017 17:22:55"}
|
15
15
|
def from_http_push_params(params)
|
16
|
+
self.class.normalize_http_push_params(params)
|
16
17
|
%w(PhoneNumber Status CustomerMessageId dateTime).each do |p|
|
17
18
|
raise ArgumentError.new("Missing http delivery notification push parameter #{p}. Parameters were: #{params.inspect}") if params[p].blank?
|
18
19
|
end
|
@@ -23,6 +24,7 @@ module PayCallSms
|
|
23
24
|
:phone => params['PhoneNumber'],
|
24
25
|
:message_id => params['CustomerMessageId'],
|
25
26
|
:occurred_at => params['dateTime'],
|
27
|
+
:reason_not_delivered => params['ReasonNotDelivered']
|
26
28
|
}
|
27
29
|
|
28
30
|
parse_notification_values_hash(values)
|
@@ -59,7 +61,15 @@ module PayCallSms
|
|
59
61
|
end
|
60
62
|
|
61
63
|
def self.gateway_delivery_status_to_delivery_status(gateway_status)
|
62
|
-
{inprogress: :in_progress, delivered: :delivered, failed: :failed}.with_indifferent_access[gateway_status] || :unknown
|
64
|
+
{inprogress: :in_progress, pending: :in_progress, delivered: :delivered, failed: :failed, kosher: :failed}.with_indifferent_access[gateway_status] || :unknown
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.normalize_http_push_params(params)
|
68
|
+
if params['Status'] == 'kosher'
|
69
|
+
params['ReasonNotDelivered'] = 'kosher_number'
|
70
|
+
params['dateTime'] = Time.now.strftime('%d-%m-%Y %H:%M:%s') # "12-12-2017 14:22:1"
|
71
|
+
end
|
72
|
+
params
|
63
73
|
end
|
64
74
|
|
65
75
|
end
|
@@ -74,7 +74,10 @@ module PayCallSms
|
|
74
74
|
message: message_text,
|
75
75
|
customermessageid: message_id
|
76
76
|
}
|
77
|
-
|
77
|
+
if options[:delivery_notification_url].present?
|
78
|
+
result[:deliverynotificationURL] = options[:delivery_notification_url]
|
79
|
+
result[:deliverynotificationmethod] = 'POST'
|
80
|
+
end
|
78
81
|
result[:from] = options[:sender_number]
|
79
82
|
result[:from] = options[:sender_name] if options[:sender_name].present?
|
80
83
|
result
|
data/paycall-sms.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: paycall-sms 0.1.
|
5
|
+
# stub: paycall-sms 0.1.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "paycall-sms"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Alex Tkachev"]
|
14
|
-
s.date = "2017-
|
14
|
+
s.date = "2017-12-24"
|
15
15
|
s.description = "Ruby api for sms service provider: PayCall"
|
16
16
|
s.email = "tkachev.alex@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -29,11 +29,21 @@ describe PayCallSms::DeliveryNotificationParser do
|
|
29
29
|
it 'should be delivered when status is delivered' do
|
30
30
|
http_params.update('Status' => 'delivered')
|
31
31
|
notification.delivery_status.should == :delivered
|
32
|
+
notification.reason_not_delivered.should be_blank
|
32
33
|
end
|
33
34
|
|
34
35
|
it 'should be not delivered when status is failed' do
|
35
36
|
http_params.update('Status' => 'failed')
|
36
37
|
notification.delivery_status.should == :failed
|
38
|
+
notification.reason_not_delivered.should be_blank
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should normalize http params when status is koshe' do
|
42
|
+
http_params.update('Status' => 'koshe')
|
43
|
+
notification.delivery_status.should == :failed
|
44
|
+
notification.gateway_status.should == 'kosher'
|
45
|
+
notification.occurred_at.should be_present
|
46
|
+
notification.reason_not_delivered.should == 'kosher_number'
|
37
47
|
end
|
38
48
|
|
39
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paycall-sms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Tkachev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|