sms_center 0.0.4 → 0.0.6

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27928d33e7ea40e743a0007ca1c3ebfb10f1d067834a31664d9f7f5fbee113ce
4
- data.tar.gz: 7c4fb8c1874609c52e763508556d5e562213cdedb18b045196d39a48ac785672
3
+ metadata.gz: 8cca56f5c0c00af8e1f608532b5dad34e935daef2854f825e2237851c5196e92
4
+ data.tar.gz: 363f7076826a55acc7a1e574724b35dce8a8ff5c11caa9749cf343c6187bd9e1
5
5
  SHA512:
6
- metadata.gz: 274dfc3ab958f381e2d5c2ea7d147dd63fa0560a5e024b327a2d8258e114e55128517c50db70ed6188ec76d39abd6e79a2f09a9e8720b9b992039a638284a32c
7
- data.tar.gz: fdddc58227e3106b5f6abdd6d70577a388c30b0fab09a5c11b6854991d0be38900c55d1a91a1a8d3221c31d3f75047375e44004c905be27c537e7e648d20b71d
6
+ metadata.gz: e5ef69fc6ba0a7413279f9df19a93f1e4b410942609faee3dacf0334ee52436f7cb6cd70838b6bd28d93acc9be0c440f185ee07dff9cb8f9c80a50b92265ef01
7
+ data.tar.gz: 69ae4f7425d7922841af7e3be0ffe138ca5829b036c743a321b3cfa7648336e25646a2e0e5c9e088b5cdc61cb96c4038842e1419281f1e23165418c443671898
@@ -36,14 +36,19 @@ class SmsCenter
36
36
  @@root_number_by_platform
37
37
  end
38
38
 
39
- def initialize(content, to_number, country, platform = nil)
39
+ def initialize(content, to_number, options = {})
40
40
  platform_by_country = SmsCenter.platform_by_country
41
- platform = platform_by_country[country.downcase.to_sym] || platform_by_country[:default] unless platform
42
- from_number = SmsCenter.root_number_by_platform[platform.to_sym]
43
- @request = SmsCenter.const_get(platform, false).new(content, to_number, from_number, @@keys)
41
+ country = options[:country]
42
+ platform = options[:platform]
43
+
44
+ f_platform = country ? platform_by_country[country.downcase.to_sym] : platform_by_country[:default]
45
+ f_platform = platform.downcase.capitalize if platform
46
+
47
+ from_number = SmsCenter.root_number_by_platform[f_platform.to_sym]
48
+ @request = SmsCenter.const_get(f_platform, false).new(content, to_number, from_number, @@keys)
44
49
  end
45
50
 
46
51
  def send
47
- RestClient.post(@request.api_url, @request.body, @request.headers)
52
+ HTTPClient.new.post_async(@request.api_url, @request.body, @request.headers)
48
53
  end
49
54
  end
@@ -4,8 +4,7 @@ class SmsCenter::Infobip
4
4
  api_key = keys[:INFOBIP_API_KEY]
5
5
  @api_url = 'https://5mzkg.api.infobip.com/sms/2/text/single'
6
6
  @headers = {
7
- 'Authorization' => "App #{api_key}",
8
- 'Content-Type' => 'application/json'
7
+ 'Authorization' => "App #{api_key}"
9
8
  }
10
9
  @body = {
11
10
  "to": to_number,
@@ -3,9 +3,6 @@ class SmsCenter::Nexmo
3
3
  def initialize(content, to_number, from_number, keys)
4
4
  base64key = Base64.strict_encode64("#{keys[:NEXMO_API_KEY]}:#{keys[:NEXMO_API_SECRET]}")
5
5
  @api_url = 'https://rest.nexmo.com/sms/json'
6
- @headers = {
7
- 'Content-Type' => 'application/json'
8
- }
9
6
  @body = {
10
7
  api_key: keys[:NEXMO_API_KEY],
11
8
  api_secret: keys[:NEXMO_API_SECRET],
@@ -4,8 +4,7 @@ class SmsCenter::Telerivet
4
4
  base64key = Base64.strict_encode64("#{keys[:TELERIVET_API_KEY]}:")
5
5
  @api_url = "https://api.telerivet.com/v1/projects/#{keys[:TELERIVET_PROJECT_ID]}/messages/send"
6
6
  @headers = {
7
- 'Authorization' => "Basic #{base64key}",
8
- 'Content-Type' => 'application/json'
7
+ 'Authorization' => "Basic #{base64key}"
9
8
  }
10
9
  @body = {
11
10
  "content": content,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sms_center
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Deleveree
@@ -11,19 +11,19 @@ cert_chain: []
11
11
  date: 2020-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rest-client
14
+ name: httpclient
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0
26
+ version: '0'
27
27
  description: A simple tool to using SMS third party
28
28
  email:
29
29
  executables: []
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  requirements: []
56
- rubygems_version: 3.0.6
56
+ rubygems_version: 3.0.3
57
57
  signing_key:
58
58
  specification_version: 4
59
59
  summary: Deliveree!