wepay 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wepay.rb +20 -18
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 984dedaa25f4999e812d6beb6308bf3c9d7ce7c1
|
4
|
+
data.tar.gz: 6f4797e7420823bfab43700d53e7323d378dd5de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 090ea3e5dd776694dfecc4a5cdff4d4ad275f148d978329a22d71c60481e165c29d6fb2d4c83310a07c89557c8fc416b17ef6fa49925ad59f3c3aa69ba3b6dae
|
7
|
+
data.tar.gz: 6f6f5b8f51386747cd5a3e19ff81e651b646ec3a1a5f576458b33f4c03a20a1bbd79a7086e429ba02cd4016b1ef78da358dd158b8f6bded013888148672c73c5
|
data/lib/wepay.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
##
|
2
|
-
# Copyright (c)
|
2
|
+
# Copyright (c) 2012-2016 WePay.
|
3
3
|
#
|
4
4
|
# http://opensource.org/licenses/Apache2.0
|
5
5
|
##
|
@@ -39,20 +39,17 @@ module WePay
|
|
39
39
|
attr_reader :client_secret
|
40
40
|
attr_reader :ui_endpoint
|
41
41
|
|
42
|
-
##
|
43
|
-
# Initializes the API application.
|
44
|
-
##
|
45
42
|
def initialize(client_id, client_secret, use_stage = true, api_version = nil)
|
46
|
-
@client_id
|
43
|
+
@client_id = client_id.to_s
|
47
44
|
@client_secret = client_secret.to_s
|
48
|
-
@api_version
|
45
|
+
@api_version = api_version.to_s
|
49
46
|
|
50
47
|
if use_stage
|
51
48
|
@api_endpoint = STAGE_API_ENDPOINT
|
52
|
-
@ui_endpoint
|
49
|
+
@ui_endpoint = STAGE_UI_ENDPOINT
|
53
50
|
else
|
54
51
|
@api_endpoint = PRODUCTION_API_ENDPOINT
|
55
|
-
@ui_endpoint
|
52
|
+
@ui_endpoint = PRODUCTION_UI_ENDPOINT
|
56
53
|
end
|
57
54
|
end
|
58
55
|
|
@@ -60,8 +57,10 @@ module WePay
|
|
60
57
|
# Execute a call to the WePay API.
|
61
58
|
##
|
62
59
|
def call(call, access_token = false, params = {})
|
63
|
-
|
64
|
-
|
60
|
+
path = call.start_with?('/') ? call : call.prepend('/')
|
61
|
+
url = URI.parse(api_endpoint + path)
|
62
|
+
|
63
|
+
call = Net::HTTP::Post.new(url.path, {
|
65
64
|
'Content-Type' => 'application/json',
|
66
65
|
'User-Agent' => 'WePay Ruby SDK'
|
67
66
|
})
|
@@ -83,17 +82,19 @@ module WePay
|
|
83
82
|
##
|
84
83
|
def oauth2_authorize_url(
|
85
84
|
redirect_uri,
|
86
|
-
user_email
|
87
|
-
user_name
|
88
|
-
permissions
|
85
|
+
user_email = false,
|
86
|
+
user_name = false,
|
87
|
+
permissions = "manage_accounts,collect_payments,view_user,send_money,preapprove_payments,manage_subscriptions",
|
88
|
+
user_country = false
|
89
89
|
)
|
90
90
|
url = @ui_endpoint +
|
91
91
|
'/oauth2/authorize?client_id=' + @client_id.to_s +
|
92
92
|
'&redirect_uri=' + redirect_uri +
|
93
93
|
'&scope=' + permissions
|
94
94
|
|
95
|
-
url += user_name ?
|
96
|
-
url += user_email ?
|
95
|
+
url += user_name ? '&user_name=' + CGI::escape(user_name) : ''
|
96
|
+
url += user_email ? '&user_email=' + CGI::escape(user_email) : ''
|
97
|
+
url += user_country ? '&user_country=' + CGI::escape(user_country) : ''
|
97
98
|
end
|
98
99
|
|
99
100
|
##
|
@@ -114,10 +115,11 @@ private
|
|
114
115
|
# Make the HTTP request to the endpoint.
|
115
116
|
##
|
116
117
|
def make_request(call, url)
|
117
|
-
request
|
118
|
+
request = Net::HTTP.new(url.host, url.port)
|
118
119
|
request.read_timeout = 30
|
119
|
-
request.use_ssl
|
120
|
-
|
120
|
+
request.use_ssl = true
|
121
|
+
|
122
|
+
response = request.start { |http| http.request(call) }
|
121
123
|
JSON.parse(response.body)
|
122
124
|
end
|
123
125
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wepay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WePay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The WePay SDK for Ruby lets you easily make WePay API calls from Ruby.
|
14
14
|
email: api@wepay.com
|
@@ -37,7 +37,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
37
|
version: '0'
|
38
38
|
requirements: []
|
39
39
|
rubyforge_project:
|
40
|
-
rubygems_version: 2.4
|
40
|
+
rubygems_version: 2.6.4
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: WePay SDK for Ruby
|