sms_center 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4567b272b4936f87d5ac41e6f7a6780451d0859ff25800f7cd1a5a01ff15c2dd
4
- data.tar.gz: 0f2bfae548a50ea7edcfe94aa0502925f01f861d8faa607f94fcfbd9e1042490
3
+ metadata.gz: 4c2797ea02c9a31a95b6d1bbe9d77d4e5d0950bd39dfa3e304a3dde97dcf48d3
4
+ data.tar.gz: eddfa0cc6fbf2114cfab6d234ef7af0a7940d49851ac5af2c673c6f1b0e3df5b
5
5
  SHA512:
6
- metadata.gz: 9366470c499324fdaa4dcd7706cce03907bae37f45eda2a1e9623ae7b53962e809ceac50edc28e13737553cd2a87178f4305bb7212cca0a7cc06aaee6912a4d1
7
- data.tar.gz: 891bc47345ff2f44d93fdb6dc0c51da2886b893b830d6012c88a550d56aee0f390c505c3354d4a59400ccaab2b65c4972dd8faa741df80a952d441af4d402c6a
6
+ metadata.gz: 6ca5569f6d3bc1cd10476549bcba85fa0a7be5b4f83ea7c3f74092e948b51f638425cd940cba33c81895d3bccf84b788d516892cc2e964843e22ec56c8eccb9d
7
+ data.tar.gz: e6968624761038dd2330800b7320d23057290631aba2640fd42f13a48b634e223e4a8c2ce9ff08638372f49d7618eaa9cc1af0996f46b93bbf9659efa0ea5f19
@@ -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.present? ? platform_by_country[country.downcase.to_sym] : platform_by_country[:default]
45
+ f_platform = platform.downcase.capitalize if platform.present?
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.8
4
+ version: 0.0.9
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: []