movile_sms 0.1.1 → 0.1.3

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: 6d424ce4e29e7b818da4f0e14cfda93db5440d4a
4
- data.tar.gz: f382473f308d0148730f7877431bc7e642ccdfcf
3
+ metadata.gz: 4b0bdfbdc5cfcfa2aa5977de9e7b793f70d21466
4
+ data.tar.gz: a85ffdca3d575afa798f23bb7a1486494ff407c6
5
5
  SHA512:
6
- metadata.gz: 6eb2395522b34e7ba0a925755fac3c211fdf615a55a6259691efd0d2ed52057b65dffc375c84cd2cbb66da0b5254071e1e824adc641a5deff0570ae100b069c3
7
- data.tar.gz: 3ef9a1edb44ebd718bc6d1ea264b2fdde0149f3f6b9cf683de60913b02ba171f856e5beae8a76be3517377fd7de6e29fb75d27b92abc7bd996a5aa7590e5991b
6
+ metadata.gz: 7fead189d170801fb1eb6eb8f8fd6a316f2ccb5588a22f908fcac9d2231dc56b10f1c3fa5bf1654a684863266113377df129a5afc6ddc4eef0cbfc859ea88a7c
7
+ data.tar.gz: 0c3b3f987ab668a353607e37c5bd8885787f995541adb8759fa796bb13f7cb34fb999bf3773872d59d34a85f1b2d8dd772452a21d6eebd5417c5a88ed18bebf6
data/.gitignore CHANGED
@@ -1,9 +1,10 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
+ /.byebug_history
3
4
  /Gemfile.lock
4
5
  /_yardoc/
5
6
  /coverage/
6
7
  /doc/
7
8
  /pkg/
8
9
  /spec/reports/
9
- /tmp/
10
+ /tmp/
data/README.md CHANGED
@@ -20,13 +20,48 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
23
+ After installing the gem and registering with the movile API, instantiate the Sms class by passing its UserName and AuthenticationToken credentials.
24
24
 
25
- ## Development
25
+ ```
26
+ sms = Movile::SMS.new(username: 'Your User Name', access_token: 'Your Access Token')
27
+
28
+ ```
29
+
30
+ After instantiating the Sms class by passing the authentication parameters, call the send_message method by passing the number and text parameters.
31
+
32
+ Ps: It is mandatory to pass the country and state code before the number.
33
+
34
+ ```
35
+ sms.send_message('5511999999999', 'this is my message from movile_sms gem!')
36
+
37
+ ```
38
+
39
+ To check the status of your message, you will need to invoke the status_message (uuid) method, passing the uuid returned in the send_message send method.
40
+
41
+ ```
42
+ sms.status_message('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')
43
+
44
+ ```
45
+
46
+ The following return must be displayed if the uuid is valid.
47
+
48
+ ```
49
+ {
50
+ "id":"f9c100ff-aed0-4456-898c-e57d754c439c",
51
+ "correlationId":"client-id",
52
+ "carrierId":1,
53
+ "carrierName":"VIVO",
54
+ "destination":"5511900009999",
55
+ "sentStatusCode":2,
56
+ "sentStatus":"SENT_SUCCESS",
57
+ "sentAt":1266660300000,
58
+ "sentDate":"2010-02-20T10:05:00Z",
59
+ "campaignId":"64",
60
+ "extraInfo":"",
61
+ }
62
+ ```
26
63
 
27
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
64
 
29
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
65
 
31
66
  ## Contributing
32
67
 
data/Rakefile CHANGED
@@ -1,7 +1,6 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
3
-
1
+ require 'bundler/gem_tasks'
2
+ task default: :spec
4
3
 
5
4
  task :console do
6
- exec "irb -r movile_sms -I ./lib"
7
- end
5
+ exec 'irb -r movile -I ./lib'
6
+ end
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "movile_sms"
3
+ require 'bundler/setup'
4
+ require 'movile_sms'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "movile_sms"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start
data/lib/movile.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'httparty'
2
+ require 'json'
3
+ require 'movile_sms/version'
4
+ require 'movile_sms/sms'
5
+
6
+ # movile/movile
7
+ module Movile
8
+ end
@@ -1,30 +1,35 @@
1
- #require 'byebug'
2
-
3
- class Sms
1
+ # lib/movile_sms/sms.rb
2
+ class SMS
4
3
  include HTTParty
5
4
 
6
- BASE_API_URL = 'https://api-messaging.movile.com/v1/send-sms'
5
+ BASE_API_URL = 'https://api-messaging.movile.com/v1/send-sms'.freeze
6
+
7
+ REPORT_API_URL = 'https://api-messaging.movile.com/v1/sms-status?id='.freeze
7
8
 
8
9
  def initialize(attributes)
9
- @options = { 'UserName' => attributes[:username], 'AuthenticationToken' => attributes[:access_token], 'Content-Type' => 'application/json' }
10
+ @options['UserName'] = attributes[:username]
11
+ @options['AuthenticationToken'] = attributes[:access_token]
12
+ @options['Content-Type'] = 'application/json'
10
13
  end
11
14
 
12
15
  def send_message(number, text)
13
- if valid_number?(number) and text_size(text)
14
- body = { "destination" => number.to_s, "messageText" => text.to_s }.to_json
15
- response = self.class.post(BASE_API_URL, headers: @options, body: body )
16
- else
17
- raise "Check if the imputed number #{number} is valid or if the text has a maximum of 162 characters
18
- "
19
- end
16
+ raise 'Not Valid' unless numeric?(number) && valid_text?(text)
17
+ body = { 'destination' => number, 'messageText' => text }.to_json
18
+ response = self.class.post(BASE_API_URL, headers: @options, body: body)
19
+ response['id']
20
20
  end
21
21
 
22
- def valid_number?(number)
23
- true if Float(number) rescue false
22
+ def status_message(uuid)
23
+ response = self.class.get(REPORT_API_URL + uuid, headers: @options)
24
+ JSON.parse(response.body)
24
25
  end
25
26
 
26
- def text_size(text)
27
- text.size <= 162
27
+ # Return false if the value isn't a numeric value
28
+ def numeric?(number)
29
+ Float(number) ? true : false
28
30
  end
29
31
 
30
- end
32
+ def valid_text?(text)
33
+ text.size <= 160
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module MovileSms
2
- VERSION = "0.1.1"
2
+ VERSION = '0.1.3'.freeze
3
3
  end
data/movile_sms.gemspec CHANGED
@@ -1,35 +1,35 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'movile_sms/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "movile_sms"
8
+ spec.name = 'movile_sms'
8
9
  spec.version = MovileSms::VERSION
9
- spec.authors = ["Leandro"]
10
- spec.email = ["lndr.figueredo@gmail.com"]
11
- spec.summary = %q{Send sms messages with Movile API.}
12
- spec.description = %q{Simple way to integrate and send messages with movile API}
13
- spec.homepage = ""
10
+ spec.authors = ['Leandro']
11
+ spec.email = ['lndr.figueredo@gmail.com']
12
+ spec.summary = %('Send sms messages with Movile API.')
13
+ spec.description = %('Simple integrate and send messages with movile API')
14
+ spec.homepage = ''
14
15
 
15
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
- # to allow pushing to a single host or delete this section to allow pushing to any host.
17
16
  if spec.respond_to?(:metadata)
18
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
17
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
19
18
  else
20
- raise "RubyGems 2.0 or newer is required to protect against " \
21
- "public gem pushes."
19
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
20
+ 'public gem pushes.'
22
21
  end
23
22
 
24
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
23
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
25
24
  f.match(%r{^(test|spec|features)/})
26
25
  end
27
- spec.bindir = "exe"
26
+ spec.bindir = 'exe'
28
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
- spec.require_paths = ["lib"]
30
- spec.add_development_dependency "bundler", "~> 1.13"
31
- spec.add_development_dependency "rake", "~> 10.0"
32
- spec.add_development_dependency "minitest"
33
- spec.add_dependency "httparty"
34
- spec.add_dependency "json"
28
+ spec.require_paths = ['lib']
29
+ spec.add_development_dependency 'bundler', '~> 1.13'
30
+ spec.add_development_dependency 'rake', '~> 10.0'
31
+ spec.add_development_dependency 'minitest'
32
+ spec.add_dependency 'httparty'
33
+ spec.add_dependency 'json'
34
+ spec.add_dependency 'rubocop'
35
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: movile_sms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-30 00:00:00.000000000 Z
11
+ date: 2017-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,21 +80,34 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- description: Simple way to integrate and send messages with movile API
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: "'Simple integrate and send messages with movile API'"
84
98
  email:
85
99
  - lndr.figueredo@gmail.com
86
100
  executables: []
87
101
  extensions: []
88
102
  extra_rdoc_files: []
89
103
  files:
90
- - ".byebug_history"
91
104
  - ".gitignore"
92
105
  - Gemfile
93
106
  - README.md
94
107
  - Rakefile
95
108
  - bin/console
96
109
  - bin/setup
97
- - lib/movile_sms.rb
110
+ - lib/movile.rb
98
111
  - lib/movile_sms/sms.rb
99
112
  - lib/movile_sms/version.rb
100
113
  - movile_sms.gemspec
@@ -121,5 +134,5 @@ rubyforge_project:
121
134
  rubygems_version: 2.4.8
122
135
  signing_key:
123
136
  specification_version: 4
124
- summary: Send sms messages with Movile API.
137
+ summary: "'Send sms messages with Movile API.'"
125
138
  test_files: []
data/.byebug_history DELETED
@@ -1,63 +0,0 @@
1
- exit
2
- File.expand_path File.dirname(__FILE__)
3
- Dir.now
4
- Dir
5
- require './lib/movile_sms'
6
- ls
7
- pwd
8
- exit
9
- next
10
- body.to_json
11
- body
12
- exit
13
- body.to_json
14
- body = {:destination => number, :messageText => text }
15
- body = body: {:destination => number, :messageText => text }
16
- body = body: { 'destination' => number, 'messageText' => text }
17
- body: body: { 'destination' => number, 'messageText' => text }
18
- body
19
- number
20
- self.class.post(BASE_API_URL, body: { 'destination' => number, 'messageText' => text }.to_json, headers: @options)
21
- self.class
22
- exit
23
- attributes[:username]
24
- attributes
25
- attrubutes
26
- continue
27
- @options
28
- @options.is_a? Hash
29
- exit
30
- @options.is_a? Array
31
- @options.is_a? Hash
32
- @options
33
- continue
34
- response
35
- continue
36
- next
37
- response
38
- next
39
- response
40
- next
41
- @options
42
- continue
43
- HTTParty.post(BASE_API_URL, @options)
44
- BASE_API_URL
45
- @options
46
- continue
47
- @options
48
- exit
49
- @options
50
- @options[:query]
51
- @options
52
- @@options
53
- @options
54
- exit
55
- #{base_api_url}
56
- Sms::base_api_url
57
- base_api_url
58
- continue
59
- @username
60
- next
61
- exit
62
- attributes[0]
63
- attributes
data/lib/movile_sms.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'httparty'
2
- require 'json'
3
- require "movile_sms/version"
4
- require "movile_sms/sms"
5
-
6
- module MovileSms
7
-
8
-
9
-
10
- end