vindi 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,51 @@
1
+ module Vindi
2
+ module Rest
3
+
4
+ # Methods for the products API
5
+ # @see https://vindi.github.io/api-docs/dist/#!/products
6
+ module Product
7
+
8
+ # List products for the authenticate user
9
+ # @option options [Integer] :page (1) Page number.
10
+ # @option options [Integer] :merchant Merchant account
11
+ # @return [Array<Hash>] A list of products for a merchant.
12
+ # @example Get all products from merchant vindi
13
+ def list_products(options = {})
14
+ get('products', options)[:products]
15
+ end
16
+
17
+ # Get a single product from a merchant
18
+ #
19
+ # @param product_id [Integer] ID of the product
20
+ # @return [Hash] The product you requested, if it exists
21
+ # @see https://vindi.github.io/api-docs/dist/#!/products/GET_version_products_id_format
22
+ # @example Get product #2 from vindi
23
+ # client.product(2)
24
+ def product(product_id, options = {})
25
+ get("products/#{product_id}", options)[:product]
26
+ end
27
+
28
+ # Create a product for a merchant vindi
29
+ #
30
+ # @option options [Hash] :options product attributes
31
+ # @see https://vindi.github.io/api-docs/dist/#!/products/POST_version_products_format
32
+ # @return [Hash] The product created
33
+ # @example Create a product for a merchant vindi
34
+ # client.create_product(name: 'My product', interval: 12)
35
+ def create_product(options = {})
36
+ post('products', options)[:product]
37
+ end
38
+
39
+ # Edit a product
40
+ #
41
+ # @params product_id [Integer] ID of the product
42
+ # @option options [Hash] :options product attributes
43
+ # @see https://vindi.github.io/api-docs/dist/#!/products/PUT_version_products_id_format
44
+ # @example Update product #2
45
+ # client.update_product(2, name: 'My product', interval: 3)
46
+ def update_product(product_id, options = {})
47
+ put("products/#{product_id}", options)[:product]
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,54 @@
1
+ module Vindi
2
+ module Rest
3
+
4
+ # Methods for the product_items API
5
+ # @see https://vindi.github.io/api-docs/dist/#!/product_items
6
+ module ProductItem
7
+
8
+ # Get a single product_item from a merchant
9
+ #
10
+ # @param product_item_id [Integer] ID of the product_item
11
+ # @return [Hash] The product_item you requested, if it exists
12
+ # @see https://vindi.github.io/api-docs/dist/#!/product_items/GET_version_product_items_id_format
13
+ # @example Get product_item #2 from vindi
14
+ # client.product_item(2)
15
+ def product_item(product_item_id, options = {})
16
+ get("product_items/#{product_item_id}", options)[:product_item]
17
+ end
18
+
19
+ # Create a product_item for a merchant vindi
20
+ #
21
+ # @option options [Hash] :options product_item attributes
22
+ # @see https://vindi.github.io/api-docs/dist/#!/product_items/POST_version_product_items_format
23
+ # @return [Hash] The product_item created
24
+ # @example Create a product_item for a merchant vindi
25
+ # client.create_product_item(product_id: 26, quantity: 1)
26
+ def create_product_item(options = {})
27
+ post('product_items', options)[:product_item]
28
+ end
29
+
30
+ # Edit a product_item
31
+ #
32
+ # @params product_item_id [Integer] ID of the product_item
33
+ # @option options [Hash] :options product_item attributes
34
+ # @see https://vindi.github.io/api-docs/dist/#!/product_items/PUT_version_product_items_id_format
35
+ # @example Update product_item #2
36
+ # client.update_product_item(2, quantity: 2)
37
+ def update_product_item(product_item_id, options = {})
38
+ put("product_items/#{product_item_id}", options)[:product_item]
39
+ end
40
+
41
+ # Delete a product_item from merchant vindi
42
+ #
43
+ # @params product_item_id [Integer] ID of the product_item
44
+ # @option options [Hash] :options product_item attributes
45
+ #
46
+ # @see https://vindi.github.io/api-docs/dist/#!/product_items/DELETE_version_product_items_id_format
47
+ # @example Delete product_item #2
48
+ # client.delete_product_item(2)
49
+ def delete_product_item(product_item_id, options = {})
50
+ delete("product_items/#{product_item_id}", options)[:product_item]
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,18 @@
1
+ module Vindi
2
+ module Rest
3
+
4
+ # Methods for the roles API
5
+ # @see https://vindi.github.io/api-docs/dist/#!/roles
6
+ module Role
7
+
8
+ # List roles for the authenticate user
9
+ # @option options [Integer] :page (1) Page number.
10
+ # @option options [Integer] :merchant Merchant account
11
+ # @return [Array<Hash>] A list of roles for a merchant.
12
+ # @example Get all roles from merchant vindi
13
+ def list_roles(options = {})
14
+ get('roles', options)[:roles]
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,85 @@
1
+ module Vindi
2
+ module Rest
3
+
4
+ # Methods for the subscriptions API
5
+ # @see https://vindi.github.io/api-docs/dist/#!/subscriptions
6
+ module Subscription
7
+
8
+ # List subscription for the authenticate user
9
+ # @return [Array<Hash>] A list of subscriptions for a merchant.
10
+ # @example Get all subscriptions from merchant vindi
11
+ def list_subscriptions(options = {})
12
+ get('subscriptions', options)[:subscriptions]
13
+ end
14
+
15
+ # Get a single subscription from a merchant
16
+ #
17
+ # @param subscription_id [Integer] ID of the subscription
18
+ # @return [Hash] The subscription you requested, if it exists
19
+ # @see https://vindi.github.io/api-docs/dist/#!/subscriptions/GET_version_subscriptions_id_format
20
+ # @example Get subscription #2 from vindi
21
+ # client.subscription(2)
22
+ def subscription(subscription_id, options = {})
23
+ get("subscriptions/#{subscription_id}", options)[:subscription]
24
+ end
25
+
26
+ # Create a subscription for a merchant vindi
27
+ #
28
+ # @option options [Hash] :options subscription attributes
29
+ # @see https://vindi.github.io/api-docs/dist/#!/subscriptions/POST_version_subscriptions_format
30
+ # @return [Hash] The subscription created
31
+ # @example Create a subscription for a merchant vindi
32
+ # client.create_subscription(plan_id: 12, customer_id: 142,
33
+ # payment_method_code: "credit_card",
34
+ # product_items: [{ product_id: 14 }])
35
+ def create_subscription(options = {})
36
+ post('subscriptions', options)[:subscription]
37
+ end
38
+
39
+ # Edit a subscription
40
+ #
41
+ # @params subscription_id [Integer] ID of the subscription
42
+ # @option options [Hash] :options subscription attributes
43
+ # @see https://vindi.github.io/api-docs/dist/#!/subscriptions/PUT_version_subscriptions_id_format
44
+ # @example update subscription #2
45
+ # client.update_subscription(2, payment_method_code: "debit_card")
46
+ def update_subscription(subscription_id, options = {})
47
+ put("subscriptions/#{subscription_id}", options)[:subscription]
48
+ end
49
+
50
+ # Renew a subscription
51
+ #
52
+ # @params subscription_id [Integer] ID of the subscription
53
+ # @option options [Hash] :options subscription attributes
54
+ # @see https://vindi.github.io/api-docs/dist/#!/subscriptions/PUT_version_subscriptions_id_format
55
+ # @example update subscription #2
56
+ # client.renew_subscription(2)
57
+ def renew_subscription(subscription_id, options = {})
58
+ post("subscriptions/#{subscription_id}/renew", options)[:subscription]
59
+ end
60
+
61
+ # Reactivate a subscription
62
+ #
63
+ # @params subscription_id [Integer] ID of the subscription
64
+ # @option options [Hash] :options subscription attributes
65
+ # @see https://vindi.github.io/api-docs/dist/#!/subscriptions/PUT_version_subscriptions_id_format
66
+ # @example update subscription #2
67
+ # client.reactivate_subscription(2)
68
+ def reactivate_subscription(subscription_id, options = {})
69
+ post("subscriptions/#{subscription_id}/reactivate", options)[:subscription]
70
+ end
71
+
72
+ # Delete a subscription from merchant vindi
73
+ #
74
+ # @params subscription_id [Integer] ID of the subscription
75
+ # @option options [Hash] :options subscription attributes
76
+ #
77
+ # @see https://vindi.github.io/api-docs/dist/#!/subscriptions/DELETE_version_subscriptions_id_format
78
+ # @example Delete subscription #2
79
+ # client.delete_subscription(2)
80
+ def delete_subscription(subscription_id, options = {})
81
+ delete("subscriptions/#{subscription_id}", options)[:subscription]
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,53 @@
1
+ module Vindi
2
+ module Rest
3
+
4
+ # Methods for the Transaction API
5
+ # @see https://vindi.github.io/api-docs/dist/#!/transactions
6
+ module Transaction
7
+
8
+ # List transactions for the authenticate user
9
+ # @option options [Integer] :page (1) Page number.
10
+ # @option options [Integer] :merchant Merchant account
11
+ # @return [Array<Hash>] A list of transactions for a merchant.
12
+ # @example Get all transactions from merchant vindi
13
+ def list_transactions(options = {})
14
+ get('transactions', options)[:transactions]
15
+ end
16
+
17
+ # Get a single transaction from a merchant
18
+ #
19
+ # @param transaction_id [Integer] ID of the transaction
20
+ # @return [Hash] The transaction you requested, if it exists
21
+ # @see https://vindi.github.io/api-docs/dist/#!/transactions/GET_version_transactions_id_format
22
+ # @example Get transaction #2 from vindi
23
+ # client.transaction(2)
24
+ def transaction(transaction_id, options = {})
25
+ get("transactions/#{transaction_id}", options)[:transaction]
26
+ end
27
+
28
+ # Create a transaction for a merchant vindi
29
+ #
30
+ # @option options [Hash] :options transaction attributes
31
+ # @see https://vindi.github.io/api-docs/dist/#!/transactions/POST_version_transactions_format
32
+ # @return [Hash] The transaction created
33
+ # @example Create a transaction for a merchant vindi
34
+ # client.create_transaction(charge_id: 475, amount: 100,
35
+ # payment_method_code: 'cash',
36
+ # paid_at: "2017-09-08")
37
+ def create_transaction(options = {})
38
+ post('transactions', options)[:transaction]
39
+ end
40
+
41
+ # Edit a transaction
42
+ #
43
+ # @params transaction_id [Integer] ID of the transaction
44
+ # @option options [Hash] :options transaction attributes
45
+ # @see https://vindi.github.io/api-docs/dist/#!/transactions/PUT_version_transactions_id_format
46
+ # @example Update transaction #2
47
+ # client.update_transaction(2, gateway_transaction_id: "gateway-transaction_id")
48
+ def update_transaction(transaction_id, options = {})
49
+ put("transactions/#{transaction_id}", options)[:transaction]
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,32 @@
1
+ module Vindi
2
+ module Rest
3
+
4
+ # Methods for the Usage API
5
+ # @see https://vindi.github.io/api-docs/dist/#!/usages
6
+ module Usage
7
+
8
+ # Create a usage for a merchant vindi
9
+ #
10
+ # @option options [Hash] :options usage attributes
11
+ # @see https://vindi.github.io/api-docs/dist/#!/usages/POST_version_usages_format
12
+ # @return [Hash] The usage created
13
+ # @example Create a usage for a merchant vindi
14
+ # client.create_usage(period_id: 382, product_item_id: 141,
15
+ # quantity: 3)
16
+ def create_usage(options = {})
17
+ post('usages', options)[:usage]
18
+ end
19
+
20
+ # Delete a usage
21
+ #
22
+ # @params usage_id [Integer] ID of the usage
23
+ # @option options [Hash] :options usage attributes
24
+ # @see https://vindi.github.io/api-docs/dist/#!/usages/DELETE_version_usages_id_format
25
+ # @example Delete usage #2
26
+ # client.delete_usage(2)
27
+ def delete_usage(usage_id, options = {})
28
+ delete("usages/#{usage_id}", options)[:usage]
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,17 @@
1
+ module Vindi
2
+ module Rest
3
+
4
+ # Methods for the users API
5
+ # @see https://vindi.github.io/api-docs/dist/#!/users
6
+ module User
7
+
8
+ # List the authenticated current user
9
+ #
10
+ # @return <Hash> a current user.
11
+ # @example Get current user from merchant vindi
12
+ def current_user
13
+ get('users/current')[:user]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module Vindi
2
+ VERSION = '0.0.1'
3
+ end
data/vindi.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "vindi/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vindi"
8
+ spec.version = Vindi::VERSION
9
+ spec.authors = %q{Vindi}
10
+ spec.email = %q{developers@vindi.com.br}
11
+ spec.summary = %q{Ruby toolkit for working with the Vindi API}
12
+ spec.description = %q{Simple wrapper for the Vindi API}
13
+ spec.homepage = 'https://github.com/vindi/vindi-ruby'
14
+ spec.files = %w(README.md Rakefile vindi.gemspec)
15
+ spec.files += Dir.glob("lib/**/*.rb")
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_dependency 'faraday', '~> 0.13.1'
19
+ spec.add_development_dependency "bundler", "~> 1.15"
20
+ spec.add_development_dependency "rake", "~> 10.0"
21
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vindi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Vindi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-12 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.13.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.13.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Simple wrapper for the Vindi API
56
+ email: developers@vindi.com.br
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - README.md
62
+ - Rakefile
63
+ - lib/vindi.rb
64
+ - lib/vindi/client.rb
65
+ - lib/vindi/configuration.rb
66
+ - lib/vindi/connection.rb
67
+ - lib/vindi/default.rb
68
+ - lib/vindi/error.rb
69
+ - lib/vindi/request.rb
70
+ - lib/vindi/response/raise_error.rb
71
+ - lib/vindi/rest.rb
72
+ - lib/vindi/rest/bill.rb
73
+ - lib/vindi/rest/bill_item.rb
74
+ - lib/vindi/rest/charge.rb
75
+ - lib/vindi/rest/customer.rb
76
+ - lib/vindi/rest/discount.rb
77
+ - lib/vindi/rest/import_batch.rb
78
+ - lib/vindi/rest/invoice.rb
79
+ - lib/vindi/rest/issue.rb
80
+ - lib/vindi/rest/merchant.rb
81
+ - lib/vindi/rest/merchant_user.rb
82
+ - lib/vindi/rest/message.rb
83
+ - lib/vindi/rest/movement.rb
84
+ - lib/vindi/rest/notification.rb
85
+ - lib/vindi/rest/payment_method.rb
86
+ - lib/vindi/rest/payment_profile.rb
87
+ - lib/vindi/rest/period.rb
88
+ - lib/vindi/rest/plan.rb
89
+ - lib/vindi/rest/product.rb
90
+ - lib/vindi/rest/product_item.rb
91
+ - lib/vindi/rest/role.rb
92
+ - lib/vindi/rest/subscription.rb
93
+ - lib/vindi/rest/transaction.rb
94
+ - lib/vindi/rest/usage.rb
95
+ - lib/vindi/rest/user.rb
96
+ - lib/vindi/version.rb
97
+ - vindi.gemspec
98
+ homepage: https://github.com/vindi/vindi-ruby
99
+ licenses: []
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.6.13
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Ruby toolkit for working with the Vindi API
121
+ test_files: []