ap_ruby_sdk 0.1.1 → 0.1.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: c066834f38c3354b64e002a38b2eccace0b4e5c8
4
- data.tar.gz: eed246cb9c481de6d2c40f86e8c459b9af16a514
3
+ metadata.gz: fb915f29f7b64fb116403b25a6cceef8d590c62d
4
+ data.tar.gz: 1bc2ba007d5399a684a5a48ca943f49623121b6c
5
5
  SHA512:
6
- metadata.gz: 42b82f61cc6a12c31f8ad482cf1e9ead8ad76fe59afa721c4d7afe8c4a6876a8d4500daab758d3ed7076d40c20b7c89c56d7bb2c546a821de5cf294f2ee181f6
7
- data.tar.gz: 5133bdc976a5872de9810e1fe1abca5a00509571cfbd29011b4ec1795848ddd21e7c83a6a108ebb61f14284640f46e9ffa28414cc283315b998bd8c0203e7ab6
6
+ metadata.gz: c23ca2e6a4c2290d024be60f89d315229168000acc34c4cf0bce569d009c08a305df18f51c751e65305a73fc7a6ff52a60826fca4a72a743a77c405120e0cab3
7
+ data.tar.gz: 7edc6c5ff9551e339ab70effa9fc2a3e55ffdaca13cbb984e12f2ef9b90e7c6cc31a5a150e175f83dde5b9bdf78d3d751596f72d92636f5bbe1521af6ac472f3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ap_ruby_sdk (0.1.1)
4
+ ap_ruby_sdk (0.1.2)
5
5
  oj
6
6
  rest-client (~> 1.8)
7
7
  webmock
data/README.md CHANGED
@@ -21,9 +21,11 @@ Or install it yourself as:
21
21
  In your initializing files add line:
22
22
 
23
23
  if Rails.env.production?
24
- ApRubySdk.api_key = 'Live key provided from your AP account'
24
+ ApRubySdk.api_secret_key = 'Live secret key provided from your AP account'
25
+ ApRubySdk.api_public_key = 'Live public key provided from your AP account'
25
26
  else
26
- ApRubySdk.api_key = 'Test key provided from your AP account'
27
+ ApRubySdk.api_secret_key = 'Test secret key provided from your AP account'
28
+ ApRubySdk.api_public_key = 'Test public key provided from your AP account'
27
29
  end
28
30
 
29
31
  ## Usage
data/lib/ap_ruby_sdk.rb CHANGED
@@ -15,6 +15,7 @@ require 'ap_ruby_sdk/errors/payment_error'
15
15
 
16
16
  # AP operations
17
17
  require 'ap_ruby_sdk/api_operations/create'
18
+ require 'ap_ruby_sdk/api_operations/create_phone_verification'
18
19
  require 'ap_ruby_sdk/api_operations/list'
19
20
  require 'ap_ruby_sdk/api_operations/retrieve'
20
21
 
@@ -36,17 +37,23 @@ require 'ap_ruby_sdk/refund_reason'
36
37
  require 'ap_ruby_sdk/subscription'
37
38
  require 'ap_ruby_sdk/pagination'
38
39
  require 'ap_ruby_sdk/preauthorization'
40
+ require 'ap_ruby_sdk/website'
41
+ require 'ap_ruby_sdk/payment_option'
39
42
 
40
43
  module ApRubySdk
41
44
  @api_base = 'https://api.alternativepayments.com/api'
42
45
 
43
46
  class << self
44
- attr_accessor :api_key, :api_base
47
+ attr_accessor :api_secret_key, :api_base, :api_public_key
45
48
  end
46
49
 
47
- def self.request(method, url, api_key, params={}, headers={})
48
- unless api_key ||= @api_key
49
- raise AuthenticationError.new('No API key provided.')
50
+ def self.request(method, url, api_secret_key, api_public_key, params={}, headers={})
51
+ unless api_secret_key ||= @api_secret_key
52
+ raise AuthenticationError.new('No Secret API key provided.')
53
+ end
54
+
55
+ unless api_public_key ||= @api_public_key
56
+ raise AuthenticationError.new('No Public API key provided.')
50
57
  end
51
58
 
52
59
  url = api_url(url)
@@ -65,7 +72,7 @@ module ApRubySdk
65
72
  end
66
73
 
67
74
  request_opts = {
68
- :headers => request_headers(api_key).update(headers),
75
+ :headers => request_headers(api_secret_key).update(headers),
69
76
  :open_timeout => 30,
70
77
  :timeout => 80,
71
78
  :method => method,
@@ -96,10 +103,10 @@ module ApRubySdk
96
103
  map { |k, v| "#{k}=#{Util.url_encode(v)}" }.join('&')
97
104
  end
98
105
 
99
- def self.request_headers(api_key)
106
+ def self.request_headers(api_secret_key)
100
107
  {
101
108
  :user_agent => "AlternativePayments Ruby SDK v#{ApRubySdk::VERSION}",
102
- :authorization => "Basic #{Base64.strict_encode64(api_key)}",
109
+ :authorization => "Basic #{Base64.strict_encode64(api_secret_key)}",
103
110
  :content_type => :json
104
111
  }
105
112
  end
@@ -2,8 +2,8 @@ module ApRubySdk
2
2
  module ApiOperations
3
3
  module Create
4
4
  module ClassMethods
5
- def create(params={}, url_prefix=nil, api_key=nil)
6
- response = ApRubySdk.request(:post, url_with_prefix(url_prefix), api_key, params)
5
+ def create(params={}, url_prefix=nil, api_secret_key=nil, api_public_key=nil)
6
+ response = ApRubySdk.request(:post, url_with_prefix(url_prefix), api_secret_key, api_public_key, params)
7
7
  Util.convert_to_ap_object(response, self.url)
8
8
  end
9
9
  end
@@ -0,0 +1,22 @@
1
+ module ApRubySdk
2
+ module ApiOperations
3
+ module CreatePhoneVerification
4
+ module ClassMethods
5
+ def create_phone_verification(params={}, url_prefix=nil, api_secret_key=nil, api_public_key=nil)
6
+ api_public_key ||= ApRubySdk.api_public_key
7
+
8
+ params.update({
9
+ :key => api_public_key
10
+ })
11
+
12
+ response = ApRubySdk.request(:post, url_with_prefix(url_prefix), api_secret_key, api_public_key, params)
13
+ Util.convert_to_ap_object(response, self.url)
14
+ end
15
+ end
16
+
17
+ def self.included(base)
18
+ base.extend(ClassMethods)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -2,8 +2,8 @@ module ApRubySdk
2
2
  module ApiOperations
3
3
  module List
4
4
  module ClassMethods
5
- def all(pagination_options={}, url_prefix=nil, api_key=nil)
6
- response = ApRubySdk.request(:get, "#{url_with_prefix(url_prefix)}/", api_key, pagination_options)
5
+ def all(pagination_options={}, url_prefix=nil, api_secret_key=nil, api_public_key=nil)
6
+ response = ApRubySdk.request(:get, "#{url_with_prefix(url_prefix)}/", api_secret_key, api_public_key, pagination_options)
7
7
  list = Util.convert_to_ap_object(response[self.list_members], self.url)
8
8
  ApRubySdk::Collection.new(
9
9
  'items' => list,
@@ -2,8 +2,8 @@ module ApRubySdk
2
2
  module ApiOperations
3
3
  module Retrieve
4
4
  module ClassMethods
5
- def retrieve(id, retrieve_options={}, url_prefix=nil, api_key=nil)
6
- response = ApRubySdk.request(:get, "#{url_with_prefix(url_prefix)}/#{id}", api_key, retrieve_options)
5
+ def retrieve(id, retrieve_options={}, url_prefix=nil, api_secret_key=nil, api_public_key=nil)
6
+ response = ApRubySdk.request(:get, "#{url_with_prefix(url_prefix)}/#{id}", api_secret_key, api_public_key, retrieve_options)
7
7
  Util.convert_to_ap_object(response, self.url)
8
8
  end
9
9
  end
@@ -0,0 +1,16 @@
1
+ module ApRubySdk
2
+ class PaymentOption < ApiResource
3
+ include ApRubySdk::ApiOperations::Retrieve
4
+
5
+ attr_accessor :hasSmsVerification,
6
+ :url
7
+
8
+ def self.url
9
+ '/paymentoptions'
10
+ end
11
+
12
+ def self.list_members
13
+ :paymentoptions
14
+ end
15
+ end
16
+ end
@@ -1,6 +1,7 @@
1
1
  module ApRubySdk
2
2
  class PhoneVerification < ApiResource
3
3
  include ApRubySdk::ApiOperations::Create
4
+ include ApRubySdk::ApiOperations::CreatePhoneVerification
4
5
 
5
6
  attr_accessor :key,
6
7
  :phone,
@@ -70,7 +70,9 @@ module ApRubySdk
70
70
  '/plans' => Plan,
71
71
  '/refunds' => Refund,
72
72
  '/subscriptions' => Subscription,
73
- '/preauthorizations' => Preauthorization
73
+ '/preauthorizations' => Preauthorization,
74
+ '/websites' => Website,
75
+ '/paymentoptions' => PaymentOption
74
76
  }
75
77
  end
76
78
  end
@@ -1,3 +1,3 @@
1
1
  module ApRubySdk
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -0,0 +1,16 @@
1
+ module ApRubySdk
2
+ class Website < ApiResource
3
+
4
+ def self.is_phone_verification_on(payment_option=nil)
5
+ PaymentOption.retrieve(payment_option, {}, "#{self.url}/#{ApRubySdk.api_public_key}")
6
+ end
7
+
8
+ def is_phone_verification_on(payment_option=nil)
9
+ self.is_phone_verification_on(payment_option)
10
+ end
11
+
12
+ def self.url
13
+ '/websites'
14
+ end
15
+ end
16
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ap_ruby_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marjan, Nenad
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-08 00:00:00.000000000 Z
11
+ date: 2017-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -96,6 +96,7 @@ files:
96
96
  - bin/setup
97
97
  - lib/ap_ruby_sdk.rb
98
98
  - lib/ap_ruby_sdk/api_operations/create.rb
99
+ - lib/ap_ruby_sdk/api_operations/create_phone_verification.rb
99
100
  - lib/ap_ruby_sdk/api_operations/list.rb
100
101
  - lib/ap_ruby_sdk/api_operations/retrieve.rb
101
102
  - lib/ap_ruby_sdk/api_resource.rb
@@ -109,6 +110,7 @@ files:
109
110
  - lib/ap_ruby_sdk/errors/payment_error.rb
110
111
  - lib/ap_ruby_sdk/pagination.rb
111
112
  - lib/ap_ruby_sdk/payment.rb
113
+ - lib/ap_ruby_sdk/payment_option.rb
112
114
  - lib/ap_ruby_sdk/period.rb
113
115
  - lib/ap_ruby_sdk/phone_verification.rb
114
116
  - lib/ap_ruby_sdk/plan.rb
@@ -121,6 +123,7 @@ files:
121
123
  - lib/ap_ruby_sdk/util.rb
122
124
  - lib/ap_ruby_sdk/version.rb
123
125
  - lib/ap_ruby_sdk/void.rb
126
+ - lib/ap_ruby_sdk/website.rb
124
127
  homepage: http://www.alternativepayments.com/
125
128
  licenses:
126
129
  - MIT