fortytwoish 0.1.2 → 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: 817421da81bd42c0b0006f6000c631695eb1a253
4
- data.tar.gz: 550a6ab7122a648613c636d305e04faab7bc0c84
3
+ metadata.gz: e43721fd45337ec54cd14a5ca30ed3f7854daf5a
4
+ data.tar.gz: 46982c5cf8bd60973c463a44373f92bb35fb225d
5
5
  SHA512:
6
- metadata.gz: d28214ce94169752ac10d1c813638ec0fd3891d0ba89d2f18d589495fc202cab4f6a8a3949e6b864916dbafdd93d693aa23a4744934fa2c812c2b627748020fa
7
- data.tar.gz: 7e339e04e407794e924b8c224e6776d14bc5ef5edb21b0ad23c2983e12b601ef0e48f5473615615fa05fd68c40f89bfc2c9077370f27bb9cc84e2a7fcea509cd
6
+ metadata.gz: acbb71347345d21d50cd440e95cf013d72c3292f2122fd3e9fdb9dc623a52d3730c52f8df806c763e76e8aa3fcb2f75eb5222c03473bf6110c7094174a3a12ec
7
+ data.tar.gz: ca49ada97832d5541e1eb88b0c1816cc6ed97e6afd6578a43ee50cbec115e5a2d183474368ccac32d93960bc75ed9f45a80a9afe7da6857d2e5129d36a05f5ab
data/README.md CHANGED
@@ -48,4 +48,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/RushPl
48
48
 
49
49
  ## License
50
50
 
51
- GNU GPLv3
51
+ MIT
@@ -3,9 +3,9 @@ require 'json'
3
3
 
4
4
  module Fortytwoish
5
5
  class Client
6
- def initialize(number, message)
6
+ def initialize(numbers, message)
7
7
  @message = message
8
- @number = number
8
+ @numbers = Array(numbers)
9
9
  end
10
10
 
11
11
  def send
@@ -15,7 +15,7 @@ module Fortytwoish
15
15
 
16
16
  private
17
17
 
18
- attr_reader :message, :number
18
+ attr_reader :message, :numbers
19
19
 
20
20
  def configuration
21
21
  @configuration ||= Fortytwoish.configuration
@@ -23,20 +23,23 @@ module Fortytwoish
23
23
 
24
24
  def send_message
25
25
  uri = URI 'https://rest.fortytwo.com/1/im'
26
+ request = build_request(uri)
27
+ Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
28
+ http.request request
29
+ end
30
+ end
31
+
32
+ def build_request(uri)
26
33
  request = Net::HTTP::Post.new(uri.path)
27
34
  request['Content-Type'] = 'application/json; charset=utf-8'
28
35
  request['Authorization'] = "Token #{configuration.token}"
29
36
  request.body = body
30
- Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
31
- http.request request
32
- end
37
+ request
33
38
  end
34
39
 
35
40
  def body
36
41
  {
37
- destinations: [
38
- number: number
39
- ],
42
+ destinations: numbers.map { |number| { number: number } },
40
43
  'sms_content': { message: message }
41
44
  }.to_json
42
45
  end
@@ -1,3 +1,3 @@
1
1
  module Fortytwoish
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fortytwoish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Davor Babić
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-11 00:00:00.000000000 Z
11
+ date: 2018-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler