locasms 0.1.7 → 0.2.0

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
  SHA1:
3
- metadata.gz: 9fcc47dc9d81331e507553c2bec302c2fd41ea5e
4
- data.tar.gz: 875d43f697d0a428cd93e1ec8b9d06cc0cdbdb0f
3
+ metadata.gz: 60e250741b0ad19b1575ac0df29f653a873ed06c
4
+ data.tar.gz: 64c7461b17fc5d20fcf1289348928a4b7b6b1417
5
5
  SHA512:
6
- metadata.gz: d7ac7758b75ec458c061b5bad63612a7c2ae131bd363c86f14c04e51ee436788b3674db4cd2402b85baf6efa884a18ca469d383a7ad7eef4da611f453a471549
7
- data.tar.gz: e371973b0a48b2708ec2e9bae5e03964b1b7e155e18494e8e5c9d1b676ef498c725bbad2cd0ecb7d38341ac15818675df635f6ff4e13fe252955be8397dd0e7f
6
+ metadata.gz: 8fe09dc0cf3bd959a5cfac85b21d3eacec7d4b173aefaa7b9ab7de4c1ce37035e17a3fb6ba28b7b3c7a66c516e86ae2f5230d21eb736e9f0a70e004a60ebdda3
7
+ data.tar.gz: a454160d6e5557b120f497aee2dd6915a42bfe833bb1d12c1db4513812b39082fd2dec434913310d218dc685fe30cbfc1333c2319a81ffdfe08426f3b02b1cd7
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.gem
2
2
  *.rbc
3
+ *.swp
3
4
  .bundle
4
5
  .config
5
6
  .yardoc
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  > :warning: After `March 29, 2016` the base IP of the service will change as noticed on this [issue](https://github.com/mcorp/locasms/issues/6). If you don't upgrade to version `0.1.7` your app will stop delivering SMS
5
5
 
6
- Client to consume [LocaSMS api's][0].
6
+ Client to consume API's from [LocaSMS][0] and its Short Code SMS version [SMS Plataforma][1].
7
7
 
8
8
  ## Installation
9
9
 
@@ -26,8 +26,12 @@ Simple example:
26
26
  ```ruby
27
27
  require 'locasms'
28
28
 
29
+ # Default:
29
30
  cli = LocaSMS::Client.new 'LOGIN', 'PASSWORD'
30
31
 
32
+ # Short Code:
33
+ cli = LocaSMS::Client.new 'LOGIN', 'PASSWORD', type: :shortcode
34
+
31
35
  # delivering message to one mobile
32
36
  cli.deliver 'my message', '1155559999'
33
37
 
@@ -67,4 +71,5 @@ cli.campaign_release '0000'
67
71
  4. Push to the branch (`git push origin my-new-feature`)
68
72
  5. Create new Pull Request
69
73
 
70
- [0]: http://locasms.com.br/#page_2/
74
+ [0]: http://locasms.com.br
75
+ [1]: http://smsplataforma.com.br
@@ -2,16 +2,16 @@ module LocaSMS
2
2
 
3
3
  # Client to interact with LocaSMS API
4
4
  class Client
5
+ # Default API "domain"
6
+ DOMAIN = '54.173.24.177'.freeze
7
+
5
8
  # Default API address
6
- ENDPOINT = if Time.now >= Time.parse('2016-03-29T00:00:00-0300')
7
- 'http://54.173.24.177/painel/api.ashx'
8
- elsif Time.now >= Time.parse('2015-06-01T00:00:00-0300')
9
- 'http://209.133.196.250/painel/api.ashx'
10
- else
11
- 'http://173.44.33.18/painel/api.ashx'
12
- end
9
+ ENDPOINT = {
10
+ default: "http://#{DOMAIN}/painel/api.ashx",
11
+ shortcode: "http://#{DOMAIN}/shortcode/api.ashx"
12
+ }.freeze
13
13
 
14
- attr_reader :login, :password
14
+ attr_reader :login, :password, :type
15
15
 
16
16
  # @param [String] login authorized user
17
17
  # @param [String] password access password
@@ -20,7 +20,7 @@ module LocaSMS
20
20
  def initialize(login, password, opts={})
21
21
  @login = login
22
22
  @password = password
23
-
23
+ @type = opts[:type] || :default
24
24
  @rest = opts[:rest_client]
25
25
  end
26
26
 
@@ -97,13 +97,13 @@ module LocaSMS
97
97
  rest.get(:releasesms, id: id)['data']
98
98
  end
99
99
 
100
- private
100
+ private
101
101
 
102
102
  # Gets the current RestClient to handle http requests
103
103
  # @return [RestClient] you can set on class creation passing it on the options
104
104
  # @private
105
105
  def rest
106
- @rest ||= RestClient.new ENDPOINT, lgn: login, pwd: password
106
+ @rest ||= RestClient.new ENDPOINT[type], lgn: login, pwd: password
107
107
  end
108
108
 
109
109
  # Processes and returns all good numbers in a string
@@ -117,7 +117,5 @@ module LocaSMS
117
117
 
118
118
  raise Exception("Bad numbers were given: #{numbers.bad.join(',')}")
119
119
  end
120
-
121
120
  end
122
-
123
121
  end
@@ -1,3 +1,3 @@
1
1
  module LocaSMS
2
- VERSION = '0.1.7'
2
+ VERSION = '0.2.0'
3
3
  end
data/locasms.gemspec CHANGED
@@ -8,8 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.version = LocaSMS::VERSION
9
9
  spec.authors = ["Adilson Carvalho", "Leonardo Saraiva", "Marco Carvalho"]
10
10
  spec.email = ["lc.adilson@gmail.com", "vyper@maneh.org", "marco.carvalho.swasthya@gmail.com"]
11
- spec.description = %q{Cliente para o serviço de disparo de SMS da LocaSMS}
12
- spec.summary = %q{Cliente para o serviço de disparo de SMS da LocaSMS}
11
+ spec.description = %q{Cliente para o serviço de disparo de SMS da LocaSMS e de sua
12
+ versão para Short Code SMS (SMS Plataforma)}
13
+ spec.summary = %q{Cliente para disparo de SMS, regular e Short Code, através da LocaSMS/SMS Plataforma}
13
14
  spec.homepage = "https://github.com/mcorp/locasms"
14
15
  spec.license = "MIT"
15
16
 
@@ -4,52 +4,22 @@ describe LocaSMS::Client do
4
4
  let(:rest_client) { 'rest_client mock' }
5
5
  subject { LocaSMS::Client.new :login, :password, rest_client: rest_client }
6
6
 
7
- context '.ENDPOINT' do
8
- def test_when(moment_in_time)
9
- Timecop.freeze(Time.parse(moment_in_time)) do
10
- LocaSMS.send :remove_const, :Client
11
- load 'lib/locasms/client.rb'
12
- yield
13
- end
14
- end
15
-
16
- it 'prior to Jun 1st, 2015' do
17
- test_when('2015-05-31T23:59:59-0300') do
18
- expect(LocaSMS::Client::ENDPOINT).to(
19
- eq('http://173.44.33.18/painel/api.ashx')
20
- )
21
- end
22
- end
7
+ describe '::ENDPOINT' do
8
+ let(:domain) { LocaSMS::Client::DOMAIN }
23
9
 
24
- it 'is Jun 1st, 2015' do
25
- test_when('2015-06-01T00:00:00-0300') do
26
- expect(LocaSMS::Client::ENDPOINT).to(
27
- eq('http://209.133.196.250/painel/api.ashx')
28
- )
10
+ context 'When default' do
11
+ it 'Should return the default URL' do
12
+ endpoint = LocaSMS::Client::ENDPOINT[subject.type]
13
+ expect(endpoint).to eq("http://#{domain}/painel/api.ashx")
29
14
  end
30
15
  end
31
16
 
32
- it 'after Jun 1st, 2015 and prior to March 29, 2016' do
33
- test_when('2016-03-28T00:00:00-0300') do
34
- expect(LocaSMS::Client::ENDPOINT).to(
35
- eq('http://209.133.196.250/painel/api.ashx')
36
- )
37
- end
38
- end
39
-
40
- it 'is March 29, 2016' do
41
- test_when('2016-03-29T00:00:00-0300') do
42
- expect(LocaSMS::Client::ENDPOINT).to(
43
- eq('http://54.173.24.177/painel/api.ashx')
44
- )
45
- end
46
- end
17
+ context 'When default' do
18
+ subject { LocaSMS::Client.new :login, :password, type: :shortcode }
47
19
 
48
- it 'after March 29, 2016' do
49
- test_when('2017-01-01T00:00:00-0300') do
50
- expect(LocaSMS::Client::ENDPOINT).to(
51
- eq('http://54.173.24.177/painel/api.ashx')
52
- )
20
+ it 'Should return the short code URL' do
21
+ endpoint = LocaSMS::Client::ENDPOINT[subject.type]
22
+ expect(endpoint).to eq("http://#{domain}/shortcode/api.ashx")
53
23
  end
54
24
  end
55
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locasms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adilson Carvalho
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-03-29 00:00:00.000000000 Z
13
+ date: 2016-04-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -180,7 +180,8 @@ dependencies:
180
180
  - - "~>"
181
181
  - !ruby/object:Gem::Version
182
182
  version: '1.6'
183
- description: Cliente para o serviço de disparo de SMS da LocaSMS
183
+ description: "Cliente para o serviço de disparo de SMS da LocaSMS e de sua \n versão
184
+ para Short Code SMS (SMS Plataforma)"
184
185
  email:
185
186
  - lc.adilson@gmail.com
186
187
  - vyper@maneh.org
@@ -236,7 +237,8 @@ rubyforge_project:
236
237
  rubygems_version: 2.5.2
237
238
  signing_key:
238
239
  specification_version: 4
239
- summary: Cliente para o serviço de disparo de SMS da LocaSMS
240
+ summary: Cliente para disparo de SMS, regular e Short Code, através da LocaSMS/SMS
241
+ Plataforma
240
242
  test_files:
241
243
  - spec/lib/locasms/client_spec.rb
242
244
  - spec/lib/locasms/helpers/date_time_helper_spec.rb