capitalone-api 0.1.0 → 0.2.1

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: d5f446c613a844ab3a323cc99d64a286a189e277
4
- data.tar.gz: 67723cc7c70a74528d991378934b7497fed337b9
3
+ metadata.gz: 45aa3518427e8eed02de0bd463e6cd7498d01f06
4
+ data.tar.gz: 2cbab6f02b4d1a3100dbe51513d65f2228aadf46
5
5
  SHA512:
6
- metadata.gz: 356d980a8b1bc026b8fad16216a3435c0bffb10cb383c2b6f88db467abe75266b5c947d72bf744f984b29c6396dc2e39822691b653c524eb9040537706e1d710
7
- data.tar.gz: d6fec7673833fa2e52504f2b8c54a9fbec0eda0c402be75e950c09a0197b854a5eef41dbf0bf5cf94d665c4ad2686f0364dff0e5a054788fe4d4294b8034e15d
6
+ metadata.gz: b942a3dd51085bf7d7affe412e24c368c0f459ca5e1f83c54c78fe7bd52436624e21f25181790029bb00ee0bf2747bad242da3580c4e822b0b3e3faba97ab47f
7
+ data.tar.gz: 1a7f47c46c9fb1471ade25eb588b3a97fe1fdf66cb44e1a0249868353e5b9a142fee3b6435b4c91a7de9ae008bac794bbcc06cab9db1596c90d71df6de6fe0da
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capitalone-api (0.1.0)
4
+ capitalone-api (0.2.1)
5
5
  multi_json (~> 1.11)
6
6
 
7
7
  GEM
@@ -1,4 +1,5 @@
1
1
  require 'multi_json'
2
+ require_relative 'utils'
2
3
  require_relative 'resources/rewards_resource'
3
4
 
4
5
  module CapitalOneAPI
@@ -61,9 +62,12 @@ module CapitalOneAPI
61
62
 
62
63
  private
63
64
 
64
- def base_authorize_url
65
- "#{server_url}/oauth/auz/authorize?redirect_uri=#{redirect_uri}&client_id=#{client_id}" +
66
- "&response_type=code&scope=openid"
65
+ # @param [Hash] params
66
+ def base_authorize_url(params = {})
67
+ url = "#{server_url}/oauth/auz/authorize?redirect_uri=#{redirect_uri}&client_id=#{client_id}" +
68
+ "&response_type=code"
69
+ url = CapitalOneAPI::Utils.set_params_to_url(url: url, params: params) if params.any?
70
+ url
67
71
  end
68
72
 
69
73
  end
@@ -1,8 +1,9 @@
1
1
  module CapitalOneAPI
2
2
  module RewardsResource
3
3
 
4
- def rewards_authorize_url
5
- "#{base_authorize_url}%20read_rewards_account_info"
4
+ # @param [Hash] params
5
+ def rewards_authorize_url(params = {})
6
+ "#{base_authorize_url(params)}&scope=openid%20read_rewards_account_info"
6
7
  end
7
8
 
8
9
  # @param [String] access_token
@@ -24,6 +25,7 @@ module CapitalOneAPI
24
25
  # @param [String] access_token
25
26
  # @param [String] account_id
26
27
  def get_rewards_account_details(access_token:, account_id:)
28
+ account_id = CGI.escape(account_id)
27
29
  uri = URI.parse("#{@server_url}/rewards/accounts/#{account_id}")
28
30
 
29
31
  req = Net::HTTP::Get.new(uri)
@@ -0,0 +1,24 @@
1
+ require 'cgi'
2
+ require 'json'
3
+
4
+ module CapitalOneAPI
5
+ module Utils
6
+
7
+ class << self
8
+
9
+ # @param [String] url
10
+ # @param [Hash] params
11
+ def set_params_to_url(url:, params:)
12
+ "#{url}&state=#{CGI.escape(params.to_json)}"
13
+ end
14
+
15
+ # @param [String] url
16
+ def get_params_from_url(url)
17
+ params = CGI::parse(url)['state'][0]
18
+ JSON.parse(CGI.unescape(params))
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module CapitalOneAPI
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capitalone-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Shepelev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-30 00:00:00.000000000 Z
11
+ date: 2016-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -111,6 +111,7 @@ files:
111
111
  - lib/capitalone-api.rb
112
112
  - lib/capitalone-api/client.rb
113
113
  - lib/capitalone-api/resources/rewards_resource.rb
114
+ - lib/capitalone-api/utils.rb
114
115
  - lib/capitalone-api/version.rb
115
116
  homepage: https://github.com/AlexeyShepelev/capitalone-api
116
117
  licenses:
@@ -137,4 +138,3 @@ signing_key:
137
138
  specification_version: 4
138
139
  summary: Wrapper for CapitalOne API
139
140
  test_files: []
140
- has_rdoc: