zensend 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 763343e142097259cb183048822aee92ae368ac0
4
- data.tar.gz: ce842952d1c2b3bc5a1db29bf98fcbdfad1b2f2a
3
+ metadata.gz: 0b17ed52733c9cfc9372d750aa91826d79c02747
4
+ data.tar.gz: b13e058f7593bcd36794362e68fc904fd1b38eca
5
5
  SHA512:
6
- metadata.gz: 699fe7f0819a9716a4a12250b742124fb2b624075979acd5373d6923db02e861620c83a34d403febb0873f0447c7e8f1fdd26c95b45f6c34f6e4b4972932e6c0
7
- data.tar.gz: ef74cefbc3fe51f3e4852e6b09e00b197f36fd279599ba7606e66a28d438d604efdeeb2cf0e845079d56cf2ec482c9bab35b472fa260387be170cabf5fcb5975
6
+ metadata.gz: 91bcb44224fe607cda9f288dada7f80e848fbe4aeac189afe54f8088587b585d57c86cd009c1c3bf09da5a063b3e47ed85a1044943e187f99badbd30070c8122
7
+ data.tar.gz: 3a1f80fc5ef04ade667175309e2e3b3249864e8b794b0e6346e51b0fe4c84f6f254f2616ea8177947b9eb4a57ab199c881a4d6dc86d596b70df8cdb4a356e6d5
@@ -7,15 +7,42 @@ module ZenSend
7
7
  class Client
8
8
 
9
9
  ZENSEND_URL = "https://api.zensend.io"
10
+ VERIFY_URL = "https://verify.zensend.io"
10
11
 
11
12
  attr_accessor :api_key, :url, :http_opts
12
13
 
13
- def initialize(api_key, http_opts = {open_timeout: 60, read_timeout: 60}, url = ZENSEND_URL)
14
+ def initialize(api_key, http_opts = {open_timeout: 60, read_timeout: 60}, url = ZENSEND_URL, verify_url = VERIFY_URL)
14
15
  @api_key = api_key
15
16
  @url = url
16
17
  @http_opts = http_opts
18
+ @verify_url = verify_url
17
19
  end
18
20
 
21
+ VERIFY_OPTIONS = [:message, :originator]
22
+
23
+ def create_msisdn_verification(msisdn, verify_options = {})
24
+ params = {}
25
+ params["NUMBER"] = msisdn
26
+ add_optional_param(params, verify_options, "MESSAGE", :message)
27
+ add_optional_param(params, verify_options, "ORIGINATOR", :originator)
28
+
29
+ verify_options.keys.each do |key|
30
+ raise ArgumentError.new("unknown option: #{key}") if !VERIFY_OPTIONS.include?(key)
31
+ end
32
+
33
+ result = make_request("/api/msisdn_verify", :post, params, @verify_url)
34
+
35
+ result["session"]
36
+ end
37
+
38
+ def msisdn_verification_status(session)
39
+ params = {"SESSION" => session}
40
+ json = make_request("/api/msisdn_verify?" + URI.encode_www_form(params), :get, nil, @verify_url)
41
+ json["msisdn"]
42
+ end
43
+
44
+
45
+
19
46
  ##
20
47
  # Sends an sms message
21
48
  #
@@ -92,8 +119,10 @@ module ZenSend
92
119
  options[param]
93
120
  end
94
121
 
95
- def make_request(path, method, params = {})
96
- uri = URI("#{@url}#{path}")
122
+ def make_request(path, method, params = {}, base_url = nil)
123
+
124
+ base_url = base_url || @url
125
+ uri = URI("#{base_url}#{path}")
97
126
 
98
127
  response = Net::HTTP.start(uri.hostname, uri.port, @http_opts.merge(:use_ssl => uri.scheme == "https")) {|http|
99
128
 
@@ -1,3 +1,3 @@
1
1
  module ZenSend
2
- VERSION = "0.0.1"
3
- end
2
+ VERSION = "0.0.2"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zensend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fonix
@@ -80,7 +80,7 @@ files:
80
80
  - lib/zensend.rb
81
81
  homepage: http://rubygems.org/gems/zensend_ruby_api
82
82
  licenses:
83
- - FONIX
83
+ - MIT
84
84
  metadata: {}
85
85
  post_install_message:
86
86
  rdoc_options: []