promisepay 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ module Promisepay
2
+ # Resource for the Accounts API
3
+ class AccountResource < BaseResource
4
+ end
5
+ end
@@ -0,0 +1,32 @@
1
+ module Promisepay
2
+ # Resource for the BankAccounts API
3
+ class BankAccountResource < AccountResource
4
+ def model
5
+ Promisepay::BankAccount
6
+ end
7
+
8
+ # Get bank account for a user on a marketplace.
9
+ #
10
+ # @see http://docs.promisepay.com/v2.2/docs/bank_accountsid-1
11
+ #
12
+ # @param id [String] Bank Account ID.
13
+ #
14
+ # @return [Promisepay::BankAccount]
15
+ def find(id)
16
+ response = JSON.parse(@client.get("bank_accounts/#{id}").body)
17
+ Promisepay::BankAccount.new(@client, response['bank_accounts'])
18
+ end
19
+
20
+ # Create a bank account for a user on a marketplace.
21
+ #
22
+ # @see http://docs.promisepay.com/v2.2/docs/bank_accountsid-2
23
+ #
24
+ # @param attributes [Hash] Bank Account's attributes.
25
+ #
26
+ # @return [Promisepay::BankAccount]
27
+ def create(attributes)
28
+ response = JSON.parse(@client.post('bank_accounts', attributes).body)
29
+ Promisepay::BankAccount.new(@client, response['bank_accounts'])
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,20 @@
1
+ module Promisepay
2
+ # Base resource for all the other resources to inherit from
3
+ class BaseResource
4
+ def initialize(client)
5
+ @client = client
6
+ end
7
+
8
+ def method_missing(name, *args, &block)
9
+ if instance_methods.include?(model) && respond_to?(name)
10
+ model.new(@client, id: args[0]).send(name, *args[1..-1])
11
+ else
12
+ super
13
+ end
14
+ end
15
+
16
+ def respond_to?(name, include_all = false)
17
+ super || model.new(@client).respond_to?(name, include_all)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,32 @@
1
+ module Promisepay
2
+ # Resource for the CardAccounts API
3
+ class CardAccountResource < AccountResource
4
+ def model
5
+ Promisepay::CardAccount
6
+ end
7
+
8
+ # Get card account for a user on a marketplace.
9
+ #
10
+ # @see http://docs.promisepay.com/v2.2/docs/card_accountsid-1
11
+ #
12
+ # @param id [String] Bank Account ID.
13
+ #
14
+ # @return [Promisepay::CardAccount]
15
+ def find(id)
16
+ response = JSON.parse(@client.get("card_accounts/#{id}").body)
17
+ Promisepay::CardAccount.new(@client, response['card_accounts'])
18
+ end
19
+
20
+ # Create a card account for a user on a marketplace.
21
+ #
22
+ # @see http://docs.promisepay.com/v2.2/docs/card_accountsid-2
23
+ #
24
+ # @param attributes [Hash] Bank Account's attributes.
25
+ #
26
+ # @return [Promisepay::CardAccount]
27
+ def create(attributes)
28
+ response = JSON.parse(@client.post('card_accounts', attributes).body)
29
+ Promisepay::CardAccount.new(@client, response['card_accounts'])
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,47 @@
1
+ module Promisepay
2
+ # Resource for the Fees API
3
+ class FeeResource < BaseResource
4
+ def model
5
+ Promisepay::Fee
6
+ end
7
+
8
+ # List all fees for a marketplace
9
+ #
10
+ # @see http://docs.promisepay.com/v2.2/docs/fees-1
11
+ #
12
+ # @param options [Hash] Optional options.
13
+ # @option options [Integer] :limit Can ask for up to 200 fees. default: 10
14
+ # @option options [Integer] :offset Pagination help. default: 0
15
+ #
16
+ # @return [Array<Promisepay::Fee>] List all fees for a marketplace.
17
+ def find_all(options = {})
18
+ response = JSON.parse(@client.get('fees', options).body)
19
+ fees = response.key?('fees') ? response['fees'] : []
20
+ fees.map { |attributes| Promisepay::Fee.new(@client, attributes) }
21
+ end
22
+
23
+ # Get a single fee for a marketplace
24
+ #
25
+ # @see http://docs.promisepay.com/v2.2/docs/feesid
26
+ #
27
+ # @param id [String] Marketplace Fee ID.
28
+ #
29
+ # @return [Promisepay::Fee]
30
+ def find(id)
31
+ response = JSON.parse(@client.get("fees/#{id}").body)
32
+ Promisepay::Fee.new(@client, response['fees'])
33
+ end
34
+
35
+ # Create a fee for a marketplace
36
+ #
37
+ # @see http://docs.promisepay.com/v2.2/docs/fee_lists
38
+ #
39
+ # @param attributes [Hash] Item's attributes.
40
+ #
41
+ # @return [Promisepay::Item]
42
+ def create(attributes)
43
+ response = JSON.parse(@client.post('fees', attributes).body)
44
+ Promisepay::Fee.new(@client, response['fees'])
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,47 @@
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
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +1,47 @@
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
@@ -0,0 +1,4 @@
1
+ # Gem version
2
+ module Promisepay
3
+ VERSION = '0.0.2'
4
+ end
@@ -0,0 +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', '~> 0'
24
+ spec.add_dependency 'json', '~> 0'
25
+ spec.add_development_dependency 'bundler', '~> 1.7'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: promisepay
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Romain Vigo Benia
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: Gem to wrap promisepay.com API.
70
+ email:
71
+ - romain.vigobenia@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - LICENSE.txt
77
+ - README.md
78
+ - Rakefile
79
+ - lib/promisepay.rb
80
+ - lib/promisepay/client.rb
81
+ - lib/promisepay/configurable.rb
82
+ - lib/promisepay/default.rb
83
+ - lib/promisepay/error.rb
84
+ - lib/promisepay/models/account.rb
85
+ - lib/promisepay/models/bank_account.rb
86
+ - lib/promisepay/models/base_model.rb
87
+ - lib/promisepay/models/card_account.rb
88
+ - lib/promisepay/models/fee.rb
89
+ - lib/promisepay/models/item.rb
90
+ - lib/promisepay/models/paypal_account.rb
91
+ - lib/promisepay/models/transaction.rb
92
+ - lib/promisepay/models/user.rb
93
+ - lib/promisepay/resources/account_resource.rb
94
+ - lib/promisepay/resources/bank_account_resource.rb
95
+ - lib/promisepay/resources/base_resource.rb
96
+ - lib/promisepay/resources/card_account_resource.rb
97
+ - lib/promisepay/resources/fee_resource.rb
98
+ - lib/promisepay/resources/item_resource.rb
99
+ - lib/promisepay/resources/paypal_account_resource.rb
100
+ - lib/promisepay/resources/transaction_resource.rb
101
+ - lib/promisepay/resources/user_resource.rb
102
+ - lib/promisepay/version.rb
103
+ - promisepay.gemspec
104
+ homepage: https://github.com/PromisePay/promisepay-ruby
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 1.9.3
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.4.5
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Gem to wrap promisepay.com API.
128
+ test_files: []
129
+ has_rdoc: