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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWEzOWVhNDhhNDRlMmFiYWRlMzU4MDg3NzY5NjUyYTJlZDNkZDRmMA==
4
+ NDRlNTQ3YmI4YjU1MzcwNTQ5Mjg2OTllNmQ2Njg1MjcwNGViNWU1OQ==
5
5
  data.tar.gz: !binary |-
6
- NzMwYmQyN2QxNGExMTI5ZmJhZTdhZDVmMjcyYjEwYzc0ZTdjYWVkMA==
6
+ NWQ5MGY3YzkxOTA5OTkyMjY3OWU3N2Y2NWJjYzJiZjM4NGY1ZjI4ZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTA3NTgxMzI1YzM0MDhhZGZlYzE3NTI2YjM5OGEwOGY3MTViNTUwZDI0MmRh
10
- NWVlZDQ0YzU1ZGIzYzRiYjY4NTA1MDA1MWFhNTM4NmMwNjc5ZGJmYmUzYTA2
11
- ZmRiM2IyNjQ1ZTdmNmU4OWMwMGU2MTI2Y2YxY2JmNjBlZTgzYmQ=
9
+ Zjg3NDZmMjU3MWY3YTllYjY0ODA5M2RmOGFmZDNlMWRhYjE3MjczN2VjOGY5
10
+ YzliOWMzMDAxNWMxMDBiMTEwYzk0ZmIxYWNkNTZmM2EyMTNhYjRlZGZmZGE1
11
+ ZmU0NDgyODI2ZWY4MzM3NGZiMzg3NjM5OGY0MGZhOGZlZjJlOTI=
12
12
  data.tar.gz: !binary |-
13
- Y2JlM2MxM2ZlODE3M2E5YTI1NDE5NTQ0MTM4Y2IyYzY5MmUwOGM3YmY1MjRl
14
- ZDlkY2RlNTc3YTM5MjIwMTVmMDRhYzhlYWY2MmVjMTNhZDJjMDYzNDczMjc4
15
- ODEyNDRlNzU1MGZkNGE1ODI1NTZjM2UxMjEzNzdmZTZkYjhlMzU=
13
+ ZTc3Y2IwNDU1ZTkwNTY3MDFhOGRmNjY1MDM4MTMwYmNlYzIwZThkNDc2YjAz
14
+ YWE5MzNhYWUxYTY5NTYxMjg1OWUyMTBmYjQ5YTdkNmJhOGVkMjczZWJhMjU0
15
+ MDI2ZDIxOGU1MDE5MmFhYjIwNWFlOGJlMTFiMTI4M2QwMDViYjc=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
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
@@ -24,7 +24,8 @@ module PayCallSms
24
24
  phone: params['sender'],
25
25
  reply_to_phone: params['recipient'],
26
26
  text: params['content'],
27
- message_id: params['msgId']
27
+ message_id: params['msgId'],
28
+ received_at: params['receivedTime'],
28
29
  )
29
30
  end
30
31
 
@@ -74,7 +74,10 @@ module PayCallSms
74
74
  message: message_text,
75
75
  customermessageid: message_id
76
76
  }
77
- result[:deliverynotificationURL] = options[:delivery_notification_url] if options[:delivery_notification_url].present?
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
@@ -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.0 ruby lib
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.0"
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-11-24"
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.0
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-24 00:00:00.000000000 Z
11
+ date: 2017-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty