promisepay 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +378 -163
- data/Rakefile +1 -1
- data/lib/promisepay.rb +13 -13
- data/lib/promisepay/client.rb +146 -147
- data/lib/promisepay/configurable.rb +49 -49
- data/lib/promisepay/default.rb +47 -47
- data/lib/promisepay/error.rb +92 -92
- data/lib/promisepay/models/account.rb +5 -5
- data/lib/promisepay/models/bank_account.rb +28 -28
- data/lib/promisepay/models/base_model.rb +23 -23
- data/lib/promisepay/models/card_account.rb +26 -26
- data/lib/promisepay/models/fee.rb +5 -5
- data/lib/promisepay/models/item.rb +197 -197
- data/lib/promisepay/models/paypal_account.rb +26 -26
- data/lib/promisepay/models/transaction.rb +24 -24
- data/lib/promisepay/models/user.rb +63 -63
- data/lib/promisepay/resources/account_resource.rb +5 -5
- data/lib/promisepay/resources/bank_account_resource.rb +32 -32
- data/lib/promisepay/resources/base_resource.rb +20 -20
- data/lib/promisepay/resources/card_account_resource.rb +32 -32
- data/lib/promisepay/resources/fee_resource.rb +47 -47
- data/lib/promisepay/resources/item_resource.rb +53 -53
- data/lib/promisepay/resources/paypal_account_resource.rb +32 -32
- data/lib/promisepay/resources/token_resource.rb +22 -28
- data/lib/promisepay/resources/transaction_resource.rb +35 -35
- data/lib/promisepay/resources/user_resource.rb +59 -59
- data/lib/promisepay/version.rb +4 -4
- data/promisepay.gemspec +27 -27
- metadata +13 -14
- data/lib/promisepay/models/token.rb +0 -7
@@ -1,53 +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, 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
|
+
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
|
@@ -1,28 +1,22 @@
|
|
1
|
-
module Promisepay
|
2
|
-
# Resource for the
|
3
|
-
class TokenResource < BaseResource
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# @
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
response
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
1
|
+
module Promisepay
|
2
|
+
# Resource for the Tokens API
|
3
|
+
class TokenResource < BaseResource
|
4
|
+
# Create a new token for an item
|
5
|
+
#
|
6
|
+
# @see http://docs.promisepay.com/v2.2/docs/request_session_token
|
7
|
+
#
|
8
|
+
# @param attributes [Hash] Token's attributes.
|
9
|
+
#
|
10
|
+
# @return [Hash]
|
11
|
+
def create(type = :session, attributes)
|
12
|
+
case type
|
13
|
+
when :session
|
14
|
+
if attributes && attributes[:fee_ids] && attributes[:fee_ids].is_a?(Array)
|
15
|
+
attributes[:fee_ids] = attributes[:fee_ids].join(',')
|
16
|
+
end
|
17
|
+
response = @client.get('request_session_token', attributes)
|
18
|
+
JSON.parse(response.body)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
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,59 +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
|
-
|
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
|
+
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
|
data/lib/promisepay/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Gem version
|
2
|
-
module Promisepay
|
3
|
-
VERSION = '0.0.
|
4
|
-
end
|
1
|
+
# Gem version
|
2
|
+
module Promisepay
|
3
|
+
VERSION = '0.0.5'
|
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
|