promisepay 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,47 +1,53 @@
1
- module Promisepay
2
- # Resource for the Items API
3
- class ItemResource < BaseResource
4
- def model
5
- Promisepay::Item
6
- end
7
-
8
- # List all items for a marketplace
9
- #
10
- # @see http://docs.promisepay.com/v2.2/docs/items
11
- #
12
- # @param options [Hash] Optional options.
13
- # @option options [Integer] :limit Can ask for up to 200 items. default: 10
14
- # @option options [Integer] :offset Pagination help. default: 0
15
- #
16
- # @return [Array<Promisepay::Item>] List all items for a marketplace.
17
- def find_all(options = {})
18
- response = JSON.parse(@client.get('items', options).body)
19
- items = response.key?('items') ? response['items'] : []
20
- items.map { |attributes| Promisepay::Item.new(@client, attributes) }
21
- end
22
-
23
- # Get a single item for a marketplace
24
- #
25
- # @see http://docs.promisepay.com/v2.2/docs/itemsid
26
- #
27
- # @param id [String] Marketplace item ID.
28
- #
29
- # @return [Promisepay::Item]
30
- def find(id)
31
- response = JSON.parse(@client.get("items/#{id}").body)
32
- Promisepay::Item.new(@client, response['items'])
33
- end
34
-
35
- # Create an item for a marketplace
36
- #
37
- # @see http://docs.promisepay.com/v2.2/docs/items-1
38
- #
39
- # @param attributes [Hash] Item's attributes.
40
- #
41
- # @return [Promisepay::Item]
42
- def create(attributes)
43
- response = JSON.parse(@client.post('items', attributes).body)
44
- Promisepay::Item.new(@client, response['items'])
45
- end
46
- end
47
- end
1
+ module Promisepay
2
+ # Resource for the Items API
3
+ class ItemResource < BaseResource
4
+ def model
5
+ Promisepay::Item
6
+ end
7
+
8
+ # List all items for a marketplace
9
+ #
10
+ # @see http://docs.promisepay.com/v2.2/docs/items
11
+ #
12
+ # @param options [Hash] Optional options.
13
+ # @option options [Integer] :limit Can ask for up to 200 items. default: 10
14
+ # @option options [Integer] :offset Pagination help. default: 0
15
+ #
16
+ # @return [Array<Promisepay::Item>] List all items for a marketplace.
17
+ def find_all(options = {})
18
+ response = JSON.parse(@client.get('items', options).body)
19
+ items = response.key?('items') ? response['items'] : []
20
+ items.map { |attributes| Promisepay::Item.new(@client, attributes) }
21
+ end
22
+
23
+ # Get a single item for a marketplace
24
+ #
25
+ # @see http://docs.promisepay.com/v2.2/docs/itemsid
26
+ #
27
+ # @param id [String] Marketplace item ID.
28
+ #
29
+ # @return [Promisepay::Item]
30
+ def find(id, type = :full)
31
+ case type
32
+ when :full
33
+ response = JSON.parse(@client.get("items/#{id}").body)
34
+ Promisepay::Item.new(@client, response['items'])
35
+ when :status
36
+ response = JSON.parse(@client.get("items/#{id}/status").body)
37
+ Promisepay::Item.new(@client, response['items'])
38
+ end
39
+ end
40
+
41
+ # Create an item for a marketplace
42
+ #
43
+ # @see http://docs.promisepay.com/v2.2/docs/items-1
44
+ #
45
+ # @param attributes [Hash] Item's attributes.
46
+ #
47
+ # @return [Promisepay::Item]
48
+ def create(attributes)
49
+ response = JSON.parse(@client.post('items', attributes).body)
50
+ Promisepay::Item.new(@client, response['items'])
51
+ end
52
+ end
53
+ end
@@ -1,32 +1,32 @@
1
- module Promisepay
2
- # Resource for the PaypalAccounts API
3
- class PaypalAccountResource < AccountResource
4
- def model
5
- Promisepay::PaypalAccount
6
- end
7
-
8
- # Get paypal account for a user on a marketplace.
9
- #
10
- # @see http://docs.promisepay.com/v2.2/docs/paypal_accountsid-1
11
- #
12
- # @param id [String] Paypal Account ID.
13
- #
14
- # @return [Promisepay::PaypalAccount]
15
- def find(id)
16
- response = JSON.parse(@client.get("paypal_accounts/#{id}").body)
17
- Promisepay::PaypalAccount.new(@client, response['paypal_accounts'])
18
- end
19
-
20
- # Create a Paypal account for a user on a marketplace.
21
- #
22
- # @see http://docs.promisepay.com/v2.2/docs/paypal_accountsid-2
23
- #
24
- # @param attributes [Hash] Paypal Account's attributes.
25
- #
26
- # @return [Promisepay::PaypalAccount]
27
- def create(attributes)
28
- response = JSON.parse(@client.post('paypal_accounts', attributes).body)
29
- Promisepay::PaypalAccount.new(@client, response['paypal_accounts'])
30
- end
31
- end
32
- end
1
+ module Promisepay
2
+ # Resource for the PaypalAccounts API
3
+ class PaypalAccountResource < AccountResource
4
+ def model
5
+ Promisepay::PaypalAccount
6
+ end
7
+
8
+ # Get paypal account for a user on a marketplace.
9
+ #
10
+ # @see http://docs.promisepay.com/v2.2/docs/paypal_accountsid-1
11
+ #
12
+ # @param id [String] Paypal Account ID.
13
+ #
14
+ # @return [Promisepay::PaypalAccount]
15
+ def find(id)
16
+ response = JSON.parse(@client.get("paypal_accounts/#{id}").body)
17
+ Promisepay::PaypalAccount.new(@client, response['paypal_accounts'])
18
+ end
19
+
20
+ # Create a Paypal account for a user on a marketplace.
21
+ #
22
+ # @see http://docs.promisepay.com/v2.2/docs/paypal_accountsid-2
23
+ #
24
+ # @param attributes [Hash] Paypal Account's attributes.
25
+ #
26
+ # @return [Promisepay::PaypalAccount]
27
+ def create(attributes)
28
+ response = JSON.parse(@client.post('paypal_accounts', attributes).body)
29
+ Promisepay::PaypalAccount.new(@client, response['paypal_accounts'])
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,28 @@
1
+ module Promisepay
2
+ # Resource for the Users API
3
+ class TokenResource < BaseResource
4
+ def model
5
+ Promisepay::Token
6
+ end
7
+
8
+ # Create a new token for an item
9
+ #
10
+ # @see http://docs.promisepay.com/v2.2/docs/request_session_token
11
+ #
12
+ # @param attributes [Hash] Token's attributes.
13
+ #
14
+ # @return [Promisepay::Token]
15
+ def create(type = :session, attributes)
16
+ case type
17
+ when :session
18
+ if attributes && attributes[:fee_ids] && attributes[:fee_ids].is_a?(Array)
19
+ attributes[:fee_ids] = attributes[:fee_ids].join(",")
20
+ end
21
+ attributes[:token_type] = 1
22
+ response = JSON.parse(@client.post('token_auths', attributes).body)
23
+ response
24
+ end
25
+ end
26
+
27
+ end
28
+ end
@@ -1,35 +1,35 @@
1
- module Promisepay
2
- # Resource for the Transactions API
3
- class TransactionResource < BaseResource
4
- def model
5
- Promisepay::Transaction
6
- end
7
-
8
- # List all transactions for a marketplace
9
- #
10
- # @see http://docs.promisepay.com/v2.2/docs/transactions
11
- #
12
- # @param options [Hash] Optional options.
13
- # @option options [Integer] :limit Can ask for up to 200 transactions. default: 10
14
- # @option options [Integer] :offset Pagination help. default: 0
15
- #
16
- # @return [Array<Promisepay::Transaction>] List all transactions for a marketplace.
17
- def find_all(options = {})
18
- response = JSON.parse(@client.get('transactions', options).body)
19
- transactions = response.key?('transactions') ? response['transactions'] : []
20
- transactions.map { |attributes| Promisepay::Transaction.new(@client, attributes) }
21
- end
22
-
23
- # Get a single transaction for a marketplace
24
- #
25
- # @see http://docs.promisepay.com/v2.2/docs/transactionsid
26
- #
27
- # @param id [String] transaction ID.
28
- #
29
- # @return [Promisepay::Transaction]
30
- def find(id)
31
- response = JSON.parse(@client.get("transactions/#{id}").body)
32
- Promisepay::Transaction.new(@client, response['transactions'])
33
- end
34
- end
35
- end
1
+ module Promisepay
2
+ # Resource for the Transactions API
3
+ class TransactionResource < BaseResource
4
+ def model
5
+ Promisepay::Transaction
6
+ end
7
+
8
+ # List all transactions for a marketplace
9
+ #
10
+ # @see http://docs.promisepay.com/v2.2/docs/transactions
11
+ #
12
+ # @param options [Hash] Optional options.
13
+ # @option options [Integer] :limit Can ask for up to 200 transactions. default: 10
14
+ # @option options [Integer] :offset Pagination help. default: 0
15
+ #
16
+ # @return [Array<Promisepay::Transaction>] List all transactions for a marketplace.
17
+ def find_all(options = {})
18
+ response = JSON.parse(@client.get('transactions', options).body)
19
+ transactions = response.key?('transactions') ? response['transactions'] : []
20
+ transactions.map { |attributes| Promisepay::Transaction.new(@client, attributes) }
21
+ end
22
+
23
+ # Get a single transaction for a marketplace
24
+ #
25
+ # @see http://docs.promisepay.com/v2.2/docs/transactionsid
26
+ #
27
+ # @param id [String] transaction ID.
28
+ #
29
+ # @return [Promisepay::Transaction]
30
+ def find(id)
31
+ response = JSON.parse(@client.get("transactions/#{id}").body)
32
+ Promisepay::Transaction.new(@client, response['transactions'])
33
+ end
34
+ end
35
+ end
@@ -1,47 +1,59 @@
1
- module Promisepay
2
- # Resource for the Users API
3
- class UserResource < BaseResource
4
- def model
5
- Promisepay::User
6
- end
7
-
8
- # List all users for a marketplace
9
- #
10
- # @see http://docs.promisepay.com/v2.2/docs/users
11
- #
12
- # @param options [Hash] Optional options.
13
- # @option options [Integer] :limit Can ask for up to 200 users. default: 10
14
- # @option options [Integer] :offset Pagination help. default: 0
15
- #
16
- # @return [Array<Promisepay::User>] List all users for a marketplace.
17
- def find_all(options = {})
18
- response = JSON.parse(@client.get('users', options).body)
19
- users = response.key?('users') ? response['users'] : []
20
- users.map { |attributes| Promisepay::User.new(@client, attributes) }
21
- end
22
-
23
- # Get a single user
24
- #
25
- # @see http://docs.promisepay.com/v2.2/docs/usersid
26
- #
27
- # @param id [String] Marketplace user ID.
28
- #
29
- # @return [Promisepay::User]
30
- def find(id)
31
- response = JSON.parse(@client.get("users/#{id}").body)
32
- Promisepay::User.new(@client, response['users'])
33
- end
34
-
35
- # Create a new user for a marketplace
36
- #
37
- # @see http://docs.promisepay.com/v2.2/docs/users-1
38
- #
39
- # @param attributes [Hash] User's attributes.
40
- #
41
- # @return [Promisepay::User]
42
- def create(attributes)
43
- response = JSON.parse(@client.post('users', attributes).body)
44
- Promisepay::User.new(@client, response['users'])
45
- end
46
- end
47
- end
1
+ module Promisepay
2
+ # Resource for the Users API
3
+ class UserResource < BaseResource
4
+ def model
5
+ Promisepay::User
6
+ end
7
+
8
+ # List all users for a marketplace
9
+ #
10
+ # @see http://docs.promisepay.com/v2.2/docs/users
11
+ #
12
+ # @param options [Hash] Optional options.
13
+ # @option options [Integer] :limit Can ask for up to 200 users. default: 10
14
+ # @option options [Integer] :offset Pagination help. default: 0
15
+ #
16
+ # @return [Array<Promisepay::User>] List all users for a marketplace.
17
+ def find_all(options = {})
18
+ response = JSON.parse(@client.get('users', options).body)
19
+ users = response.key?('users') ? response['users'] : []
20
+ users.map { |attributes| Promisepay::User.new(@client, attributes) }
21
+ end
22
+
23
+ # Get a single user
24
+ #
25
+ # @see http://docs.promisepay.com/v2.2/docs/usersid
26
+ #
27
+ # @param id [String] Marketplace user ID.
28
+ #
29
+ # @return [Promisepay::User]
30
+ def find(id)
31
+ response = JSON.parse(@client.get("users/#{id}").body)
32
+ Promisepay::User.new(@client, response['users'])
33
+ end
34
+
35
+ # Create a new user for a marketplace
36
+ #
37
+ # @see http://docs.promisepay.com/v2.2/docs/users-1
38
+ #
39
+ # @param attributes [Hash] User's attributes.
40
+ #
41
+ # @return [Promisepay::User]
42
+ def create(attributes)
43
+ response = JSON.parse(@client.post('users', attributes).body)
44
+ Promisepay::User.new(@client, response['users'])
45
+ end
46
+
47
+ # Update a user for a marketplace
48
+ #
49
+ # @see http://docs.promisepay.com/v2.2/docs/users-1
50
+ #
51
+ # @param attributes [Hash] User's attributes.
52
+ #
53
+ # @return [Promisepay::User]
54
+ def update(attributes)
55
+ response = JSON.parse(@client.patch('users', attributes).body)
56
+ Promisepay::User.new(@client, response['users'])
57
+ end
58
+ end
59
+ end
@@ -1,4 +1,4 @@
1
- # Gem version
2
- module Promisepay
3
- VERSION = '0.0.3'
4
- end
1
+ # Gem version
2
+ module Promisepay
3
+ VERSION = '0.0.4'
4
+ end
data/promisepay.gemspec CHANGED
@@ -1,27 +1,27 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'promisepay/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'promisepay'
8
- spec.version = Promisepay::VERSION
9
- spec.authors = ['Romain Vigo Benia']
10
- spec.email = ['romain.vigobenia@gmail.com']
11
- spec.summary = 'Gem to wrap promisepay.com API.'
12
- spec.description = spec.summary
13
- spec.homepage = 'https://github.com/PromisePay/promisepay-ruby'
14
- spec.license = 'MIT'
15
-
16
- spec.files = %w(LICENSE.txt README.md Rakefile promisepay.gemspec)
17
- spec.files += Dir.glob('lib/**/*')
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ['lib']
20
-
21
- spec.required_ruby_version = '>= 1.9.3'
22
-
23
- spec.add_dependency 'faraday'
24
- spec.add_dependency 'json'
25
- spec.add_development_dependency 'bundler', '~> 1.7'
26
- spec.add_development_dependency 'rake', '~> 10.0'
27
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'promisepay/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'promisepay'
8
+ spec.version = Promisepay::VERSION
9
+ spec.authors = ['Romain Vigo Benia']
10
+ spec.email = ['romain.vigobenia@gmail.com']
11
+ spec.summary = 'Gem to wrap promisepay.com API.'
12
+ spec.description = spec.summary
13
+ spec.homepage = 'https://github.com/PromisePay/promisepay-ruby'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = %w(LICENSE.txt README.md Rakefile promisepay.gemspec)
17
+ spec.files += Dir.glob('lib/**/*')
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.required_ruby_version = '>= 1.9.3'
22
+
23
+ spec.add_dependency 'faraday'
24
+ spec.add_dependency 'json'
25
+ spec.add_development_dependency 'bundler', '~> 1.7'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promisepay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romain Vigo Benia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-19 00:00:00.000000000 Z
11
+ date: 2015-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.7'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.7'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '10.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '10.0'
69
69
  description: Gem to wrap promisepay.com API.
@@ -88,6 +88,7 @@ files:
88
88
  - lib/promisepay/models/fee.rb
89
89
  - lib/promisepay/models/item.rb
90
90
  - lib/promisepay/models/paypal_account.rb
91
+ - lib/promisepay/models/token.rb
91
92
  - lib/promisepay/models/transaction.rb
92
93
  - lib/promisepay/models/user.rb
93
94
  - lib/promisepay/resources/account_resource.rb
@@ -97,6 +98,7 @@ files:
97
98
  - lib/promisepay/resources/fee_resource.rb
98
99
  - lib/promisepay/resources/item_resource.rb
99
100
  - lib/promisepay/resources/paypal_account_resource.rb
101
+ - lib/promisepay/resources/token_resource.rb
100
102
  - lib/promisepay/resources/transaction_resource.rb
101
103
  - lib/promisepay/resources/user_resource.rb
102
104
  - lib/promisepay/version.rb
@@ -111,17 +113,17 @@ require_paths:
111
113
  - lib
112
114
  required_ruby_version: !ruby/object:Gem::Requirement
113
115
  requirements:
114
- - - ">="
116
+ - - '>='
115
117
  - !ruby/object:Gem::Version
116
118
  version: 1.9.3
117
119
  required_rubygems_version: !ruby/object:Gem::Requirement
118
120
  requirements:
119
- - - ">="
121
+ - - '>='
120
122
  - !ruby/object:Gem::Version
121
123
  version: '0'
122
124
  requirements: []
123
125
  rubyforge_project:
124
- rubygems_version: 2.4.5
126
+ rubygems_version: 2.4.6
125
127
  signing_key:
126
128
  specification_version: 4
127
129
  summary: Gem to wrap promisepay.com API.