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 +4 -4
- data/README.md +1 -1
- data/lib/fortytwoish/client.rb +12 -9
- data/lib/fortytwoish/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e43721fd45337ec54cd14a5ca30ed3f7854daf5a
|
4
|
+
data.tar.gz: 46982c5cf8bd60973c463a44373f92bb35fb225d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acbb71347345d21d50cd440e95cf013d72c3292f2122fd3e9fdb9dc623a52d3730c52f8df806c763e76e8aa3fcb2f75eb5222c03473bf6110c7094174a3a12ec
|
7
|
+
data.tar.gz: ca49ada97832d5541e1eb88b0c1816cc6ed97e6afd6578a43ee50cbec115e5a2d183474368ccac32d93960bc75ed9f45a80a9afe7da6857d2e5129d36a05f5ab
|
data/README.md
CHANGED
data/lib/fortytwoish/client.rb
CHANGED
@@ -3,9 +3,9 @@ require 'json'
|
|
3
3
|
|
4
4
|
module Fortytwoish
|
5
5
|
class Client
|
6
|
-
def initialize(
|
6
|
+
def initialize(numbers, message)
|
7
7
|
@message = message
|
8
|
-
@
|
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, :
|
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
|
-
|
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
|
data/lib/fortytwoish/version.rb
CHANGED
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.
|
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
|
+
date: 2018-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|