paypal-sdk-permissions 1.96.2 → 1.96.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NDBlOGRlNmEyZmJkNTU3MTRkMDVhZWZlOGQ4Mjg3MjMyZjFhOWRhOQ==
5
+ data.tar.gz: !binary |-
6
+ NzdkMjMzMGZhOTY0NGFiNjk0MjI2ZjQ5MmUwYzVkNGM2ODNlN2Y2Nw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NjQwZjBlOTE4NWI4YWU2Y2NiNDQ1NTJiMmI0ZTlkYmM3NWZjMTA4ZDk4Zjk5
10
+ YTc5YzYxNDYzOTg0YzY2MzI4YWNlMDYyNTRlZTE3NjA1ODRiNmE5ZDE4MDE1
11
+ MDk0YzMzNjU1YjA5NTI2ZDJiNzg5N2UyMTg1ZDViMzgxOTY1ZTg=
12
+ data.tar.gz: !binary |-
13
+ MGMxYWY3Y2I5Zjc0ODQ1NzgzNzgyODVjNmI5MjFkNDcyYzM0NjZlZmE3ODRk
14
+ MWNhN2I0MWRjMGIyZmRjOWE1NTFmYTA3ZWNiYWVhMWI3NTQ0Mzk2MDIxODcz
15
+ M2FlMzIyZDk3MDM3NmE4NmQ3MWZjZTNiZjU5Mzg2NTk3NTY2YjI=
data/Gemfile CHANGED
@@ -8,7 +8,7 @@ if File.exist? File.expand_path('../samples/permissions_samples.gemspec', __FILE
8
8
  gem 'permissions_samples', :path => 'samples', :require => false
9
9
  group :test do
10
10
  gem 'rspec-rails', :require => false
11
- gem 'capybara', :require => false
11
+ gem 'capybara', '~> 2.0.3', :require => false
12
12
  end
13
13
  end
14
14
 
data/README.md CHANGED
@@ -6,110 +6,61 @@ The PayPal Permission SDK provides Ruby APIs for developers to request and obtai
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'paypal-sdk-permissions'
9
+ ```ruby
10
+ gem 'paypal-sdk-permissions'
11
+ ```
10
12
 
11
13
  And then execute:
12
14
 
13
- $ bundle
15
+ ```sh
16
+ $ bundle
17
+ ```
14
18
 
15
19
  Or install it yourself as:
16
20
 
17
- $ gem install paypal-sdk-permissions
21
+ ```sh
22
+ $ gem install paypal-sdk-permissions
23
+ ```
18
24
 
19
25
  ## Configuration
20
26
 
21
27
  For Rails application:
22
28
 
23
- rails g paypal:sdk:install
29
+ ```sh
30
+ rails g paypal:sdk:install
31
+ ```
24
32
 
25
33
  For other ruby application, create a configuration file(`config/paypal.yml`):
26
34
 
27
- development: &default
28
- username: jb-us-seller_api1.paypal.com
29
- password: WX4WTU3S8MY44S7F
30
- signature: AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy
31
- app_id: APP-80W284485P519543T
32
- http_timeout: 30
33
- mode: sandbox
34
- # # with certificate
35
- # cert_path: "config/cert_key.pem"
36
- # # with token authentication
37
- # token: ESTy2hio5WJQo1iixkH29I53RJxaS0Gvno1A6.YQXZgktxbY4I2Tdg
38
- # token_secret: ZKPhUYuwJwYsfWdzorozWO2U9pI
39
- # # with Proxy
40
- # http_proxy: http://proxy-ipaddress:3129/
41
- # # with device ip address
42
- # device_ipaddress: "127.0.0.1"
43
- test:
44
- <<: *default
45
- production:
46
- <<: *default
47
- mode: live
35
+ ```yaml
36
+ development: &default
37
+ username: jb-us-seller_api1.paypal.com
38
+ password: WX4WTU3S8MY44S7F
39
+ signature: AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy
40
+ app_id: APP-80W284485P519543T
41
+ http_timeout: 30
42
+ mode: sandbox
43
+ # # with certificate
44
+ # cert_path: "config/cert_key.pem"
45
+ # # with token authentication
46
+ # token: ESTy2hio5WJQo1iixkH29I53RJxaS0Gvno1A6.YQXZgktxbY4I2Tdg
47
+ # token_secret: ZKPhUYuwJwYsfWdzorozWO2U9pI
48
+ # # with Proxy
49
+ # http_proxy: http://proxy-ipaddress:3129/
50
+ # # with device ip address
51
+ # device_ipaddress: "127.0.0.1"
52
+ test:
53
+ <<: *default
54
+ production:
55
+ <<: *default
56
+ mode: live
57
+ ```
48
58
 
49
59
  Load Configurations from specified file:
50
60
 
51
- PayPal::SDK::Core::Config.load('config/paypal.yml', ENV['RACK_ENV'] || 'development')
52
-
53
- ## Create API object
54
-
55
- Create API object:
56
-
57
- api = PayPal::SDK::Permissions::API.new
58
-
59
- Override configuration while creating a object:
60
-
61
- api = PayPal::SDK::Permissions::API.new(:development)
62
- api = PayPal::SDK::Permissions::API.new(:development, :app_id => "XYZ")
63
- api = PayPal::SDK::Permissions::API.new(:app_id => "XYZ") # Take default environment.
64
-
65
- Change configuration:
66
-
67
- api.set_config :testing
68
- api.set_config :testing, app_id => "XYZ"
69
-
70
-
71
- ## Build Request Object
72
-
73
- To make api request, we need to build a request object.
74
-
75
- # To build a empty request object for get verified status
76
- request_permissions = api.build_request_permissions()
77
-
78
- # To build a request object with default data
79
- request_permissions = api.build_request_permissions( :callback => "http://localhost:3000/permissions/get_access_token" )
80
-
81
- The Build method can be access with camelcase or underscore:
82
-
83
- api = api.build_request_permissions()
84
- # (or)
85
- api = api.BuildRequestPermissions()
86
-
87
- ## Assign value to members
88
-
89
- Members can be access with camelcase or underscore format.
90
-
91
- request_permissions.scope = ["TRANSACTION_SEARCH","ACCOUNT_BALANCE","BILLING_AGREEMENT"]
92
-
93
- To Get members list for the given object( For Reference ):
94
-
95
- request_permission.members
96
-
97
- ## Make API Request
98
-
99
- Make api call with request object:
100
-
101
- request_permissions_response = api.request_permissions(request_permissions)
102
-
103
- Make api call with hash:
104
-
105
- request_permissions_response = api.request_permissions( :scope => ["TRANSACTION_SEARCH"], :callback => "http://localhost:3000/permissions/get_access_token" )
106
-
107
-
108
- ## Access values from response object
109
-
110
- To get response status:
111
-
112
- request_permissions_response.responseEnvelope.ack
61
+ ```ruby
62
+ PayPal::SDK::Core::Config.load('config/paypal.yml', ENV['RACK_ENV'] || 'development')
63
+ ```
113
64
 
114
65
  ## Example
115
66
 
@@ -131,23 +82,35 @@ require 'paypal-sdk-permissions'
131
82
  @request_permissions_response = @api.request_permissions(@request_permissions)
132
83
 
133
84
  # Access Response
134
- @request_permissions_response.responseEnvelope
135
- @request_permissions_response.token
85
+ if @request_permissions_response.success?
86
+ @request_permissions_response.token
87
+ @api.grant_permission_url(@request_permissions_response) # Redirect url to grant permissions
88
+ else
89
+ @request_permissions_response.error
90
+ end
136
91
  ```
137
92
 
138
- ## Samples
93
+ For more samples [https://paypal-sdk-samples.herokuapp.com/permissions/](https://paypal-sdk-samples.herokuapp.com/permissions/)
94
+
95
+ ## Samples App
139
96
 
140
97
  Add following line in rails `Gemfile`:
141
98
 
142
- gem 'paypal-sdk-permissions'
143
- gem 'permissions_samples', :git => "https://github.com/paypal/permissions-sdk-ruby.git", :group => :development
99
+ ```ruby
100
+ gem 'paypal-sdk-permissions'
101
+ gem 'permissions_samples', :git => "https://github.com/paypal/permissions-sdk-ruby.git", :group => :development
102
+ ```
144
103
 
145
104
  Configure routes(`config/routes.rb`):
146
105
 
147
- mount PermissionsSamples::Engine => "/samples" if Rails.env.development?
106
+ ```ruby
107
+ mount PermissionsSamples::Engine => "/samples" if Rails.env.development?
108
+ ```
148
109
 
149
110
  To get default paypal configuration execute:
150
111
 
151
- rails g paypal:sdk:install
112
+ ```sh
113
+ rails g paypal:sdk:install
114
+ ```
152
115
 
153
116
  Run `rails server` and check the samples.
@@ -6,6 +6,7 @@ module PayPal
6
6
  autoload :VERSION, "paypal-sdk/permissions/version"
7
7
  autoload :Services, "paypal-sdk/permissions/services"
8
8
  autoload :DataTypes, "paypal-sdk/permissions/data_types"
9
+ autoload :Urls, "paypal-sdk/permissions/urls"
9
10
  autoload :API, "paypal-sdk/permissions/api"
10
11
 
11
12
  def self.new(*args)
@@ -5,6 +5,7 @@ module PayPal
5
5
  module Permissions
6
6
  class API < Core::API::Platform
7
7
  include Services
8
+ include Urls
8
9
 
9
10
  def initialize(environment = nil, options = {})
10
11
  super(SERVICE_NAME, environment, options)
@@ -14,6 +14,22 @@ module PayPal::SDK
14
14
  end
15
15
  end
16
16
 
17
+ module ResponseStatus
18
+ Status = { :success => ["Success", "SuccessWithWarning"],
19
+ :warning => ["Warning", "SuccessWithWarning", "FailureWithWarning"],
20
+ :failure => ["Failure", "FailureWithWarning"] }
21
+
22
+ def response_status
23
+ self.responseEnvelope && self.responseEnvelope.ack
24
+ end
25
+
26
+ Status.keys.each do |status|
27
+ define_method("#{status}?") do
28
+ Status[status].include?(self.response_status)
29
+ end
30
+ end
31
+ end
32
+
17
33
  class EnumType < Core::API::DataTypes::Enum
18
34
  end
19
35
 
@@ -66,6 +82,7 @@ module PayPal::SDK
66
82
 
67
83
  class FaultMessage < DataType
68
84
  def self.load_members
85
+ include ResponseStatus
69
86
  object_of :responseEnvelope, ResponseEnvelope, :required => true
70
87
  array_of :error, ErrorData
71
88
  end
@@ -115,6 +132,7 @@ module PayPal::SDK
115
132
  # Returns the temporary request token
116
133
  class RequestPermissionsResponse < DataType
117
134
  def self.load_members
135
+ include ResponseStatus
118
136
  object_of :responseEnvelope, ResponseEnvelope, :required => true
119
137
  # Temporary token that identifies the request for permissions. This token cannot be used to access resources on the account. It can only be used to instruct the user to authorize the permissions.
120
138
  object_of :token, String
@@ -142,6 +160,7 @@ module PayPal::SDK
142
160
  # Permanent access token and token secret that can be used to make requests for protected resources owned by another account.
143
161
  class GetAccessTokenResponse < DataType
144
162
  def self.load_members
163
+ include ResponseStatus
145
164
  object_of :responseEnvelope, ResponseEnvelope, :required => true
146
165
  # Identifier for the permissions approved for this relationship.
147
166
  array_of :scope, String
@@ -169,6 +188,7 @@ module PayPal::SDK
169
188
  # The list of permissions associated with the token.
170
189
  class GetPermissionsResponse < DataType
171
190
  def self.load_members
191
+ include ResponseStatus
172
192
  object_of :responseEnvelope, ResponseEnvelope, :required => true
173
193
  # Identifier for the permissions approved for this relationship.
174
194
  array_of :scope, String
@@ -190,6 +210,7 @@ module PayPal::SDK
190
210
 
191
211
  class CancelPermissionsResponse < DataType
192
212
  def self.load_members
213
+ include ResponseStatus
193
214
  object_of :responseEnvelope, ResponseEnvelope, :required => true
194
215
  array_of :error, ErrorData
195
216
  end
@@ -247,6 +268,7 @@ module PayPal::SDK
247
268
 
248
269
  class GetBasicPersonalDataResponse < DataType
249
270
  def self.load_members
271
+ include ResponseStatus
250
272
  object_of :responseEnvelope, ResponseEnvelope, :required => true
251
273
  object_of :response, PersonalDataList
252
274
  array_of :error, ErrorData
@@ -257,6 +279,7 @@ module PayPal::SDK
257
279
 
258
280
  class GetAdvancedPersonalDataResponse < DataType
259
281
  def self.load_members
282
+ include ResponseStatus
260
283
  object_of :responseEnvelope, ResponseEnvelope, :required => true
261
284
  object_of :response, PersonalDataList
262
285
  array_of :error, ErrorData
@@ -0,0 +1,22 @@
1
+ module PayPal
2
+ module SDK
3
+ module Permissions
4
+ module Urls
5
+ REDIRECT_ENDPOINTS = {
6
+ :live => "https://www.paypal.com/webscr",
7
+ :sandbox => "https://www.sandbox.paypal.com/webscr" }
8
+
9
+ def redirect_url(params = {})
10
+ "#{REDIRECT_ENDPOINTS[api_mode]}?#{encode_www_form(params)}"
11
+ end
12
+
13
+ def grant_permission_url(token)
14
+ token = token.token if token.respond_to?(:token)
15
+ redirect_url(:cmd => "_grant-permission", :request_token => token.to_s)
16
+ end
17
+ alias_method :request_permissions_url, :grant_permission_url
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,7 +1,7 @@
1
1
  module PayPal
2
2
  module SDK
3
3
  module Permissions
4
- VERSION = "1.96.2"
4
+ VERSION = "1.96.3"
5
5
  end
6
6
  end
7
7
  end
@@ -15,13 +15,4 @@ describe "Permissions" do
15
15
  end
16
16
  end
17
17
 
18
- describe "DataTypes" do
19
- PayPal::SDK::Permissions::DataTypes.constants.each do |const_name|
20
- it "create object for #{const_name}" do
21
- klass = PayPal::SDK::Permissions::DataTypes.const_get(const_name)
22
- klass.new.should be_a klass
23
- end
24
- end
25
- end
26
-
27
18
  end
metadata CHANGED
@@ -1,48 +1,39 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: paypal-sdk-permissions
3
- version: !ruby/object:Gem::Version
4
- hash: 403
5
- prerelease:
6
- segments:
7
- - 1
8
- - 96
9
- - 2
10
- version: 1.96.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.96.3
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - PayPal
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-03-12 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2013-04-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: paypal-sdk-core
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
26
17
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 23
29
- segments:
30
- - 0
31
- - 2
32
- - 0
33
- version: 0.2.0
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.3
34
20
  type: :runtime
35
- version_requirements: *id001
36
- description: The PayPal Permission SDK provides Ruby APIs for developers to request and obtain permissions from merchants and consumers, to execute APIs on behalf of them. The permissions include variety of operations from processing payments to accessing account transaction history
37
- email:
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.3
27
+ description: The PayPal Permission SDK provides Ruby APIs for developers to request
28
+ and obtain permissions from merchants and consumers, to execute APIs on behalf of
29
+ them. The permissions include variety of operations from processing payments to
30
+ accessing account transaction history
31
+ email:
38
32
  - DL-PP-Platform-Ruby-SDK@ebay.com
39
33
  executables: []
40
-
41
34
  extensions: []
42
-
43
35
  extra_rdoc_files: []
44
-
45
- files:
36
+ files:
46
37
  - spec/permissions_spec.rb
47
38
  - spec/spec_helper.rb
48
39
  - spec/config/paypal.yml
@@ -50,46 +41,37 @@ files:
50
41
  - lib/paypal-sdk-permissions.rb
51
42
  - lib/paypal-sdk/permissions.rb
52
43
  - lib/paypal-sdk/permissions/services.rb
44
+ - lib/paypal-sdk/permissions/urls.rb
53
45
  - lib/paypal-sdk/permissions/api.rb
54
46
  - lib/paypal-sdk/permissions/version.rb
55
47
  - lib/paypal-sdk/permissions/data_types.rb
56
48
  - Rakefile
57
49
  - README.md
58
50
  - Gemfile
59
- homepage: https://www.x.com/
51
+ homepage: https://developer.paypal.com
60
52
  licenses: []
61
-
53
+ metadata: {}
62
54
  post_install_message:
63
55
  rdoc_options: []
64
-
65
- require_paths:
56
+ require_paths:
66
57
  - lib
67
- required_ruby_version: !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
76
- required_rubygems_version: !ruby/object:Gem::Requirement
77
- none: false
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- hash: 3
82
- segments:
83
- - 0
84
- version: "0"
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
85
68
  requirements: []
86
-
87
69
  rubyforge_project:
88
- rubygems_version: 1.8.24
70
+ rubygems_version: 2.0.0
89
71
  signing_key:
90
- specification_version: 3
72
+ specification_version: 4
91
73
  summary: PayPal Permissions SDK
92
- test_files:
74
+ test_files:
93
75
  - spec/permissions_spec.rb
94
76
  - spec/spec_helper.rb
95
77
  - spec/config/paypal.yml