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.
- checksums.yaml +7 -0
- data/README.md +75 -0
- data/Rakefile +22 -0
- data/lib/vindi.rb +4 -0
- data/lib/vindi/client.rb +15 -0
- data/lib/vindi/configuration.rb +36 -0
- data/lib/vindi/connection.rb +46 -0
- data/lib/vindi/default.rb +63 -0
- data/lib/vindi/error.rb +77 -0
- data/lib/vindi/request.rb +61 -0
- data/lib/vindi/response/raise_error.rb +19 -0
- data/lib/vindi/rest.rb +32 -0
- data/lib/vindi/rest/bill.rb +95 -0
- data/lib/vindi/rest/bill_item.rb +20 -0
- data/lib/vindi/rest/charge.rb +94 -0
- data/lib/vindi/rest/customer.rb +61 -0
- data/lib/vindi/rest/discount.rb +45 -0
- data/lib/vindi/rest/import_batch.rb +38 -0
- data/lib/vindi/rest/invoice.rb +50 -0
- data/lib/vindi/rest/issue.rb +40 -0
- data/lib/vindi/rest/merchant.rb +41 -0
- data/lib/vindi/rest/merchant_user.rb +71 -0
- data/lib/vindi/rest/message.rb +41 -0
- data/lib/vindi/rest/movement.rb +21 -0
- data/lib/vindi/rest/notification.rb +103 -0
- data/lib/vindi/rest/payment_method.rb +29 -0
- data/lib/vindi/rest/payment_profile.rb +54 -0
- data/lib/vindi/rest/period.rb +52 -0
- data/lib/vindi/rest/plan.rb +51 -0
- data/lib/vindi/rest/product.rb +51 -0
- data/lib/vindi/rest/product_item.rb +54 -0
- data/lib/vindi/rest/role.rb +18 -0
- data/lib/vindi/rest/subscription.rb +85 -0
- data/lib/vindi/rest/transaction.rb +53 -0
- data/lib/vindi/rest/usage.rb +32 -0
- data/lib/vindi/rest/user.rb +17 -0
- data/lib/vindi/version.rb +3 -0
- data/vindi.gemspec +21 -0
- metadata +121 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
module Vindi
|
2
|
+
module Rest
|
3
|
+
|
4
|
+
# Methods for the merchants API
|
5
|
+
# @see https://vindi.github.io/api-docs/dist/#!/merchants
|
6
|
+
module Merchant
|
7
|
+
|
8
|
+
# List merchants 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 merchants for a merchant.
|
12
|
+
# @example Get all merchants from merchant vindi
|
13
|
+
# client.list_merchants
|
14
|
+
def list_merchants(options = {})
|
15
|
+
get('merchants', options)[:merchants]
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get a current merchant for the authenticate user
|
19
|
+
#
|
20
|
+
# @param merchant_id [Integer] ID of the merchant
|
21
|
+
# @return [Hash] The merchant you requested, if it exists
|
22
|
+
# @see https://vindi.github.io/api-docs/dist/#!/merchants/GET_version_merchants_id_format
|
23
|
+
# @example Get a current merchant from vindi
|
24
|
+
# client.current_merchant
|
25
|
+
def current_merchant
|
26
|
+
get("merchants/current")[:merchant]
|
27
|
+
end
|
28
|
+
|
29
|
+
# Edit a merchant
|
30
|
+
#
|
31
|
+
# @params merchant_id [Integer] ID of the merchant
|
32
|
+
# @option options [Hash] :options merchant attributes
|
33
|
+
# @see https://vindi.github.io/api-docs/dist/#!/merchants/PUT_version_merchants_id_format
|
34
|
+
# @example Get merchant #7 from vindi
|
35
|
+
# client.merchant(7)
|
36
|
+
def merchant(merchant_id, options = {})
|
37
|
+
get("merchants/#{merchant_id}", options)[:merchant]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Vindi
|
2
|
+
module Rest
|
3
|
+
|
4
|
+
# Methods for the merchant_users API
|
5
|
+
# @see https://vindi.github.io/api-docs/dist/#!/merchant_users
|
6
|
+
module MerchantUser
|
7
|
+
|
8
|
+
# List merchant_user for the authenticate user
|
9
|
+
# @return [Array<Hash>] A list of merchant_users for a merchant.
|
10
|
+
# @example Get all merchant_users from merchant vindi
|
11
|
+
def list_merchant_users(options = {})
|
12
|
+
get('merchant_users', options)[:merchant_users]
|
13
|
+
end
|
14
|
+
|
15
|
+
# Get a single merchant_user from a merchant
|
16
|
+
#
|
17
|
+
# @param merchant_user_id [Integer] ID of the merchant_user
|
18
|
+
# @return [Hash] The merchant_user you requested, if it exists
|
19
|
+
# @see https://vindi.github.io/api-docs/dist/#!/merchant_users/GET_version_merchant_users_id_format
|
20
|
+
# @example Get merchant_user #7 from vindi
|
21
|
+
# client.merchant_user(7)
|
22
|
+
def merchant_user(merchant_user_id, options = {})
|
23
|
+
get("merchant_users/#{merchant_user_id}", options)[:merchant_user]
|
24
|
+
end
|
25
|
+
|
26
|
+
# Create a merchant_user for a merchant vindi
|
27
|
+
#
|
28
|
+
# @option options [Hash] :options merchant_user attributes
|
29
|
+
# @see https://vindi.github.io/api-docs/dist/#!/merchant_users/POST_version_merchant_users_format
|
30
|
+
# @return [Hash] The merchant_user created
|
31
|
+
# @example Create a merchant_user for a merchant vindi
|
32
|
+
# client.create_merchant_user(name: 'John Doe', email: 'john.doe@mail.com', role_id: 10)
|
33
|
+
def create_merchant_user(options = {})
|
34
|
+
post('merchant_users', options)[:merchant_user]
|
35
|
+
end
|
36
|
+
|
37
|
+
# Edit a merchant_user
|
38
|
+
#
|
39
|
+
# @params merchant_user_id [Integer] ID of the merchant_user
|
40
|
+
# @option options [Hash] :options merchant_user attributes
|
41
|
+
# @see https://vindi.github.io/api-docs/dist/#!/merchant_users/PUT_version_merchant_users_id_format
|
42
|
+
# @example update merchant_user #7
|
43
|
+
# client.update_merchant_user(7, name: 'Joana Doe', email: 'johanadoes@mail.com')
|
44
|
+
def update_merchant_user(merchant_user_id, options = {})
|
45
|
+
put("merchant_users/#{merchant_user_id}", options)[:merchant_user]
|
46
|
+
end
|
47
|
+
|
48
|
+
# Delete a merchant_user from merchant vindi
|
49
|
+
#
|
50
|
+
# @params merchant_user_id [Integer] ID of the merchant_user
|
51
|
+
# @option options [Hash] :options merchant_user attributes
|
52
|
+
#
|
53
|
+
# @see https://vindi.github.io/api-docs/dist/#!/merchant_users/DELETE_version_merchant_users_id_format
|
54
|
+
# @example Delete merchant_user #36
|
55
|
+
# client.delete_merchant_user(36)
|
56
|
+
def delete_merchant_user(merchant_user_id, options = {})
|
57
|
+
delete("merchant_users/#{merchant_user_id}", options)[:merchant_user]
|
58
|
+
end
|
59
|
+
|
60
|
+
# Reactivate a merchant_user for a merchant vindi
|
61
|
+
#
|
62
|
+
# @see https://vindi.github.io/api-docs/dist/#!/merchant_users/POST_version_merchant_users_format
|
63
|
+
# @return [Hash] The merchant_user reactivated
|
64
|
+
# @example Reactivate a merchant_user for a merchant vindi
|
65
|
+
# client.reactivate_merchant_user(37)
|
66
|
+
def reactivate_merchant_user(merchant_user_id, options = {})
|
67
|
+
post("merchant_users/#{merchant_user_id}/reactivate", options)[:merchant_user]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Vindi
|
2
|
+
module Rest
|
3
|
+
|
4
|
+
# Methods for the messages API
|
5
|
+
# @see https://vindi.github.io/api-docs/dist/#!/messages
|
6
|
+
module Message
|
7
|
+
|
8
|
+
# List messages 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 messages for a merchant.
|
12
|
+
# @example Get all messages from merchant vindi
|
13
|
+
def list_messages(options = {})
|
14
|
+
get('messages', options)[:messages]
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get a single message from a merchant
|
18
|
+
#
|
19
|
+
# @param message_id [Integer] ID of the message
|
20
|
+
# @return [Hash] The message you requested, if it exists
|
21
|
+
# @see https://vindi.github.io/api-docs/dist/#!/messages/GET_version_messages_id_format
|
22
|
+
# @example Get message #154 from vindi
|
23
|
+
# client.message(154)
|
24
|
+
def message(message_id, options = {})
|
25
|
+
get("messages/#{message_id}", options)[:message]
|
26
|
+
end
|
27
|
+
|
28
|
+
# Create a message for a merchant vindi
|
29
|
+
#
|
30
|
+
# @option options [Hash] :options message attributes
|
31
|
+
# @see https://vindi.github.io/api-docs/dist/#!/messages/POST_version_messages_format
|
32
|
+
# @return [Hash] The message created
|
33
|
+
# @example Create a message for a merchant vindi
|
34
|
+
# client.create_message({ "customer_id": 2, "charge_id": 71,
|
35
|
+
# "notification_id": 6, "email": "cliente@email.com" })
|
36
|
+
def create_message(options = {})
|
37
|
+
post('messages', options)[:message]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Vindi
|
2
|
+
module Rest
|
3
|
+
|
4
|
+
# Methods for the Movement API
|
5
|
+
# @see https://vindi.github.io/api-docs/dist/#!/movements
|
6
|
+
module Movement
|
7
|
+
|
8
|
+
# Create a movement for a merchant vindi
|
9
|
+
#
|
10
|
+
# @option options [Hash] :options movement attributes
|
11
|
+
# @see https://vindi.github.io/api-docs/dist/#!/movements/POST_version_movement_format
|
12
|
+
# @return [Hash] The movement created
|
13
|
+
# @example Create a movement for a merchant vindi
|
14
|
+
# client.create_movement(amount: 100, movement_type: "credit",
|
15
|
+
# bill_id: 466)
|
16
|
+
def create_movement(options = {})
|
17
|
+
post('movements', options)[:movement]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Vindi
|
2
|
+
module Rest
|
3
|
+
|
4
|
+
# Methods for the notifications API
|
5
|
+
# @see https://vindi.github.io/api-docs/dist/#!/notifications
|
6
|
+
module Notification
|
7
|
+
|
8
|
+
# List notifications for the authenticate user
|
9
|
+
# @return [Array<Hash>] A list of notifications for a merchant.
|
10
|
+
# @example Get all notifications from merchant vindi
|
11
|
+
def list_notifications(options = {})
|
12
|
+
get('notifications', options)[:notifications]
|
13
|
+
end
|
14
|
+
|
15
|
+
# Get a single notification from a merchant
|
16
|
+
#
|
17
|
+
# @param notification_id [Integer] ID of the notification
|
18
|
+
# @return [Hash] The notification you requested, if it exists
|
19
|
+
# @see https://vindi.github.io/api-docs/dist/#!/notifications
|
20
|
+
# @example Get notification #2 from vindi
|
21
|
+
# client.notification(2)
|
22
|
+
def notification(notification_id, options = {})
|
23
|
+
get("notifications/#{notification_id}", options)[:notification]
|
24
|
+
end
|
25
|
+
|
26
|
+
# Create a notification for a merchant vindi
|
27
|
+
#
|
28
|
+
# @option options [Hash] :options notification attributes
|
29
|
+
# @see https://vindi.github.io/api-docs/dist/#!/notifications
|
30
|
+
# @return [Hash] The notification created
|
31
|
+
# @example Create a notification for a merchant vindi
|
32
|
+
# client.create_notification(status: "active", notification_type: "email",
|
33
|
+
# name: "Hoops", subject: "Hoops",
|
34
|
+
# content: "Hey, Hoops!",
|
35
|
+
# trigger_type: "charge_created_at",
|
36
|
+
# trigger_day: 5, bcc: "")
|
37
|
+
def create_notification(options = {})
|
38
|
+
post('notifications', options)[:notification]
|
39
|
+
end
|
40
|
+
|
41
|
+
# Edit a notification
|
42
|
+
#
|
43
|
+
# @params notification_id [Integer] ID of the notification
|
44
|
+
# @option options [Hash] :options notification attributes
|
45
|
+
# @see https://vindi.github.io/api-docs/dist/#!/notifications
|
46
|
+
# @example update notification #2
|
47
|
+
# client.update_notification(2, trigger_day: 3)
|
48
|
+
def update_notification(notification_id, options = {})
|
49
|
+
put("notifications/#{notification_id}", options)[:notification]
|
50
|
+
end
|
51
|
+
|
52
|
+
# List notification items for a merchant
|
53
|
+
#
|
54
|
+
# @params notification_id [Integer] ID of the notification
|
55
|
+
# @see https://vindi.github.io/api-docs/dist/#!/notifications
|
56
|
+
# @example notification_items #2
|
57
|
+
# client.list_notification_items(2)
|
58
|
+
def list_notification_items(notification_id, options = {})
|
59
|
+
url = "notifications/%{id}/notification_items" % { id: notification_id }
|
60
|
+
get(url, options)[:notification_items]
|
61
|
+
end
|
62
|
+
|
63
|
+
# Creates notification items for a merchant
|
64
|
+
#
|
65
|
+
# @params notification_id [Integer] ID of the notification
|
66
|
+
# @see https://vindi.github.io/api-docs/dist/#!/notifications
|
67
|
+
# @example create notification item #2
|
68
|
+
# client.create_notification_item(2, item_type: "Plan", item_id: 22)
|
69
|
+
def create_notification_item(notification_id, options = {})
|
70
|
+
url = "notifications/%{id}/notification_items" % { id: notification_id }
|
71
|
+
post(url, options)[:notification_item]
|
72
|
+
end
|
73
|
+
|
74
|
+
# Delete a notification from merchant vindi
|
75
|
+
#
|
76
|
+
# @params notification_id [Integer] ID of the notification
|
77
|
+
# @option options [Hash] :options notification attributes
|
78
|
+
#
|
79
|
+
# @see https://vindi.github.io/api-docs/dist/#!/notifications
|
80
|
+
# @example Delete notification #2
|
81
|
+
# client.delete_notification(2)
|
82
|
+
def delete_notification(notification_id, options = {})
|
83
|
+
delete("notifications/#{notification_id}", options)[:notification]
|
84
|
+
end
|
85
|
+
|
86
|
+
# Delete a notification item from merchant vindi
|
87
|
+
#
|
88
|
+
# @params notification_id [Integer] ID of the notification
|
89
|
+
# @params notification_item_id [Integer] ID of the notification item
|
90
|
+
# @option options [Hash] :options notification attributes
|
91
|
+
#
|
92
|
+
# @see https://vindi.github.io/api-docs/dist/#!/notifications
|
93
|
+
# @example Delete notification item #3
|
94
|
+
# client.delete_notification_item(2, 3)
|
95
|
+
def delete_notification_item(notification_id, notification_item_id, options = {})
|
96
|
+
url = "notifications/%{id}/notification_items/%{notification_item_id}" % {
|
97
|
+
id: notification_id, notification_item_id: notification_item_id
|
98
|
+
}
|
99
|
+
delete(url, options)[:notification_item]
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Vindi
|
2
|
+
module Rest
|
3
|
+
|
4
|
+
# Methods for the Payment Methods API
|
5
|
+
# @see https://vindi.github.io/api-docs/dist/#!/payment_methods
|
6
|
+
module PaymentMethod
|
7
|
+
|
8
|
+
# List payment methods 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 payment_methods for a merchant.
|
12
|
+
# @example Get all payment_methods from merchant vindi
|
13
|
+
def list_payment_methods(options = {})
|
14
|
+
get('payment_methods', options)[:payment_methods]
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get a single payment_method from a merchant
|
18
|
+
#
|
19
|
+
# @param payment_method_id [Integer] ID of the payment_method
|
20
|
+
# @return [Hash] The payment_method you requested, if it exists
|
21
|
+
# @see https://vindi.github.io/api-docs/dist/#!/payment_methods/GET_version_payment_methods_id_format
|
22
|
+
# @example Get payment_method #2 from vindi
|
23
|
+
# client.payment_method(2)
|
24
|
+
def payment_method(payment_method_id, options = {})
|
25
|
+
get("payment_methods/#{payment_method_id}", options)[:payment_method]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Vindi
|
2
|
+
module Rest
|
3
|
+
|
4
|
+
# Methods for the Payment profile API
|
5
|
+
# @see https://vindi.github.io/api-docs/dist/#!/payment_profiles
|
6
|
+
module PaymentProfile
|
7
|
+
|
8
|
+
# List payment_profile for the authenticate user
|
9
|
+
# @return [Array<Hash>] A list of payment_profiles for a merchant.
|
10
|
+
# @example Get all payment_profiles from merchant vindi
|
11
|
+
def list_payment_profiles(options = {})
|
12
|
+
get('payment_profiles', options)[:payment_profiles]
|
13
|
+
end
|
14
|
+
|
15
|
+
# Get a single payment_profile from a merchant
|
16
|
+
#
|
17
|
+
# @param payment_profile_id [Integer] ID of the payment_profile
|
18
|
+
# @return [Hash] The payment_profile you requested, if it exists
|
19
|
+
# @see https://vindi.github.io/api-docs/dist/#!/payment_profiles/GET_version_payment_profiles_id_format
|
20
|
+
# @example Get payment_profile #2 from vindi
|
21
|
+
# client.payment_profile(2)
|
22
|
+
def payment_profile(payment_profile_id, options = {})
|
23
|
+
get("payment_profiles/#{payment_profile_id}", options)[:payment_profile]
|
24
|
+
end
|
25
|
+
|
26
|
+
# Create a payment_profile for a merchant vindi
|
27
|
+
#
|
28
|
+
# @option options [Hash] :options payment_profile attributes
|
29
|
+
# @see https://vindi.github.io/api-docs/dist/#!/payment_profiles/POST_version_payment_profiles_format
|
30
|
+
# @return [Hash] The payment_profile created
|
31
|
+
# @example Create a payment_profile for a merchant vindi
|
32
|
+
# client.create_payment_profile(holder_name: "Jane Doe", card_cvv: "123",
|
33
|
+
# card_expiration: "12/2018", customer_id: 51)
|
34
|
+
# card_number: "5167454851671773",
|
35
|
+
# payment_method_code: "credit_card",
|
36
|
+
# payment_company_code: "mastercard",
|
37
|
+
def create_payment_profile(options = {})
|
38
|
+
post('payment_profiles', options)[:payment_profile]
|
39
|
+
end
|
40
|
+
|
41
|
+
# Delete a payment_profile from merchant vindi
|
42
|
+
#
|
43
|
+
# @params payment_profile_id [Integer] ID of the payment_profile
|
44
|
+
# @option options [Hash] :options payment_profile attributes
|
45
|
+
#
|
46
|
+
# @see https://vindi.github.io/api-docs/dist/#!/payment_profiles/DELETE_version_payment_profiles_id_format
|
47
|
+
# @example Delete payment_profile #2
|
48
|
+
# client.delete_payment_profile(2)
|
49
|
+
def delete_payment_profile(payment_profile_id, options = {})
|
50
|
+
delete("payment_profiles/#{payment_profile_id}", options)[:payment_profile]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Vindi
|
2
|
+
module Rest
|
3
|
+
|
4
|
+
# Methods for the periods API
|
5
|
+
# @see https://vindi.github.io/api-docs/dist/#!/periods
|
6
|
+
module Period
|
7
|
+
|
8
|
+
# List periods 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 periods for a merchant.
|
12
|
+
# @example Get all periods from merchant vindi
|
13
|
+
def list_periods(options = {})
|
14
|
+
get('periods', options)[:periods]
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get a single period from a merchant
|
18
|
+
#
|
19
|
+
# @param period_id [Integer] ID of the period
|
20
|
+
# @return [Hash] The period you requested, if it exists
|
21
|
+
# @see https://vindi.github.io/api-docs/dist/#!/periods/GET_version_periods_id_format
|
22
|
+
# @example Get period #2 from vindi
|
23
|
+
# client.period(2)
|
24
|
+
def period(period_id, options = {})
|
25
|
+
get("periods/#{period_id}", options)[:period]
|
26
|
+
end
|
27
|
+
|
28
|
+
# Create a period for a merchant vindi
|
29
|
+
#
|
30
|
+
# @option options [Hash] :options period attributes
|
31
|
+
# @see https://vindi.github.io/api-docs/dist/#!/periods/POST_version_periods_format
|
32
|
+
# @param bill_id [Integer] ID of the period to generate a bill
|
33
|
+
# @return [Hash] The period created
|
34
|
+
# @example Create a period for a merchant vindi
|
35
|
+
# client.create_period_bill(360)
|
36
|
+
def create_period_bill(period_id, options = {})
|
37
|
+
post("periods/#{period_id}/bill", options)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Edit a period
|
41
|
+
#
|
42
|
+
# @params period_id [Integer] ID of the period
|
43
|
+
# @option options [Hash] :options period attributes
|
44
|
+
# @see https://vindi.github.io/api-docs/dist/#!/periods/PUT_version_periods_id_format
|
45
|
+
# @example Update period #2
|
46
|
+
# client.update_period(2, name: 'My period', interval: 3)
|
47
|
+
def update_period(period_id, options = {})
|
48
|
+
put("periods/#{period_id}", options)[:period]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Vindi
|
2
|
+
module Rest
|
3
|
+
|
4
|
+
# Methods for the Plans API
|
5
|
+
# @see https://vindi.github.io/api-docs/dist/#!/plans
|
6
|
+
module Plan
|
7
|
+
|
8
|
+
# List plans 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 plans for a merchant.
|
12
|
+
# @example Get all plans from merchant vindi
|
13
|
+
def list_plans(options = {})
|
14
|
+
get('plans', options)[:plans]
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get a single plan from a merchant
|
18
|
+
#
|
19
|
+
# @param plan_id [Integer] ID of the plan
|
20
|
+
# @return [Hash] The plan you requested, if it exists
|
21
|
+
# @see https://vindi.github.io/api-docs/dist/#!/plans/GET_version_plans_id_format
|
22
|
+
# @example Get plan #2 from vindi
|
23
|
+
# client.plan(2)
|
24
|
+
def plan(plan_id, options = {})
|
25
|
+
get("plans/#{plan_id}", options)[:plan]
|
26
|
+
end
|
27
|
+
|
28
|
+
# Create a plan for a merchant vindi
|
29
|
+
#
|
30
|
+
# @option options [Hash] :options Plan attributes
|
31
|
+
# @see https://vindi.github.io/api-docs/dist/#!/plans/POST_version_plans_format
|
32
|
+
# @return [Hash] The plan created
|
33
|
+
# @example Create a plan for a merchant vindi
|
34
|
+
# client.create_plan(name: 'My Plan', interval: 12)
|
35
|
+
def create_plan(options = {})
|
36
|
+
post('plans', options)[:plan]
|
37
|
+
end
|
38
|
+
|
39
|
+
# Edit a plan
|
40
|
+
#
|
41
|
+
# @params plan_id [Integer] ID of the plan
|
42
|
+
# @option options [Hash] :options Plan attributes
|
43
|
+
# @see https://vindi.github.io/api-docs/dist/#!/plans/PUT_version_plans_id_format
|
44
|
+
# @example Update plan #2
|
45
|
+
# client.update_plan(2, name: 'My Plan', interval: 3)
|
46
|
+
def update_plan(plan_id, options = {})
|
47
|
+
put("plans/#{plan_id}", options)[:plan]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|