authy 2.4.2 → 2.5.0.pre

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: 9a0fff2e0434e2b8ded4ed1dfc6a051c5b362437
4
- data.tar.gz: af7e23303a2c387726d17f4063c412279569989c
3
+ metadata.gz: 5848053b422cea54e69e26d534fdf5b040e6fc99
4
+ data.tar.gz: a50794e2a7ac0e82e3039743688ac8965af94259
5
5
  SHA512:
6
- metadata.gz: 682692485ee64a913c686cae3e700d37aa48648f069e2ccee3b0476bbb7c9c34b611fe461e598ee477b884d26977324ea39ad350fc62bc3a5ff840db601a4278
7
- data.tar.gz: 9fefad9a32ba2028a8af9dc61bf9687af4ce2ff3951a946be4e1a1fb5d3b2ead542aaf7e20a3e4821ab3574c4edb2d02b88c71b68e09a081c95b00adf56c5f49
6
+ metadata.gz: 2732e0a2bb42b00878dd4ac3a1e7df58507bcc3f6ecfe8182cf1f24ee801306d7c07060e7d5887f4ed2099339be88eeeb425dcc6b2fa7282c2340da94da9f976
7
+ data.tar.gz: 95273c144d7d607b876fa4dc63376798149e5fc736bb31b468053b1160371dde33653b9e15f4288926427d3cb69a874e89fc49c9a1d2a9cbfba51897105744e6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.4.1
1
+ 2.5.0
@@ -12,3 +12,4 @@ require 'authy/models/user'
12
12
  require 'authy/config'
13
13
  require 'authy/api'
14
14
  require 'authy/phone_intelligence'
15
+ require 'authy/onetouch'
@@ -0,0 +1,46 @@
1
+ module Authy
2
+ class OneTouch < Authy::API
3
+
4
+ # options:
5
+ # :id
6
+ # :details Hash containing the approval request details
7
+ # :hidden_details
8
+ # :phone_number The persons phone number.
9
+ def self.send_approval_request(params)
10
+ user_id = params.delete(:id) || params.delete('id')
11
+ message = (params.delete(:message) || params.delete('message')).to_s
12
+ details = params.delete(:details) || params.delete('details')
13
+ hidden_details = params.delete(:hidden_details) || params.delete('hidden_details')
14
+ logos = params.delete(:logos) || params.delete('logos')
15
+
16
+ return invalid_response("Message cannot be blank") if message.empty?
17
+ return invalid_response('User id is invalid') unless is_digit?(user_id)
18
+
19
+ begin
20
+ self.clean_hash!(details)
21
+ self.clean_hash!(hidden_details)
22
+ rescue => e
23
+ return invalid_response("Invalid details or hidden details: #{e.message}")
24
+ end
25
+
26
+ post_request("onetouch/json/users/#{user_id}/approval_requests", {
27
+ message: message,
28
+ details: details,
29
+ hidden_details: hidden_details,
30
+ logos: logos
31
+ })
32
+ end
33
+
34
+ def self.approval_request_status(params)
35
+ uuid = params.delete(:uuid) || params.delete('uuid')
36
+
37
+ get_request("onetouch/json/approval_requests/#{uuid}")
38
+ end
39
+
40
+ private
41
+ def self.clean_hash!(test_hash)
42
+ raise "Hash expected. Got: #{test_hash.class}" unless test_hash.is_a? Hash
43
+ test_hash = test_hash.map { |k, v| [k, v.to_s] }.to_h
44
+ end
45
+ end
46
+ end
@@ -1,3 +1,3 @@
1
1
  module Authy
2
- VERSION = "2.4.2"
2
+ VERSION = "2.5.0.pre"
3
3
  end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe Authy::OneTouch do
4
+ describe ".send_approval_request" do
5
+
6
+ before do
7
+ @email = generate_email
8
+ @cellphone = generate_cellphone
9
+ @user = Authy::API.register_user(:email => @email,
10
+ :cellphone => @cellphone,
11
+ :country_code => 1)
12
+ @user.should be_ok
13
+ end
14
+
15
+ it 'creates a new approval_request for user' do
16
+ response = Authy::OneTouch.send_approval_request(
17
+ id: @user.id,
18
+ message: 'You are moving 10 BTC from your account',
19
+ details: {
20
+ 'Bank account' => '23527922',
21
+ 'Amount' => '10 BTC',
22
+ },
23
+ hidden_details: {
24
+ 'IP Address' => '192.168.0.3'
25
+ }
26
+ )
27
+
28
+ expect(response).to be_kind_of(Authy::Response)
29
+ expect(response).to be_ok
30
+ end
31
+ end
32
+
33
+ describe '.approval_request_status' do
34
+ it 'returns approval request status' do
35
+ response = Authy::OneTouch.approval_request_status(
36
+ uuid: '550e8400-e29b-41d4-a716-446655440000'
37
+ )
38
+
39
+ expect(response).to be_kind_of(Authy::Response)
40
+ expect(response).to be_ok
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.2
4
+ version: 2.5.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Authy Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-24 00:00:00.000000000 Z
11
+ date: 2015-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -146,12 +146,14 @@ files:
146
146
  - lib/authy/config.rb
147
147
  - lib/authy/core_ext.rb
148
148
  - lib/authy/models/user.rb
149
+ - lib/authy/onetouch.rb
149
150
  - lib/authy/phone_intelligence.rb
150
151
  - lib/authy/response.rb
151
152
  - lib/authy/url_helpers.rb
152
153
  - lib/authy/version.rb
153
154
  - spec/authy/api_spec.rb
154
155
  - spec/authy/config_spec.rb
156
+ - spec/authy/onetouch_spec.rb
155
157
  - spec/authy/phone_intelligence_spec.rb
156
158
  - spec/authy/response_spec.rb
157
159
  - spec/authy/url_helpers_spec.rb
@@ -171,18 +173,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
173
  version: '0'
172
174
  required_rubygems_version: !ruby/object:Gem::Requirement
173
175
  requirements:
174
- - - ">="
176
+ - - ">"
175
177
  - !ruby/object:Gem::Version
176
- version: '0'
178
+ version: 1.3.1
177
179
  requirements: []
178
180
  rubyforge_project: authy
179
- rubygems_version: 2.2.2
181
+ rubygems_version: 2.4.6
180
182
  signing_key:
181
183
  specification_version: 4
182
184
  summary: Ruby library to access Authy services
183
185
  test_files:
184
186
  - spec/authy/api_spec.rb
185
187
  - spec/authy/config_spec.rb
188
+ - spec/authy/onetouch_spec.rb
186
189
  - spec/authy/phone_intelligence_spec.rb
187
190
  - spec/authy/response_spec.rb
188
191
  - spec/authy/url_helpers_spec.rb