xendify 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +54 -0
- data/lib/xendify/api_resource.rb +25 -0
- data/lib/xendify/base.rb +29 -0
- data/lib/xendify/client.rb +47 -0
- data/lib/xendify/errors/credit_card.rb +46 -0
- data/lib/xendify/errors/disbursement.rb +15 -0
- data/lib/xendify/errors/invoice.rb +8 -0
- data/lib/xendify/errors/virtual_account.rb +40 -0
- data/lib/xendify/errors.rb +20 -0
- data/lib/xendify/middleware.rb +112 -0
- data/lib/xendify/resources/invoice.rb +47 -0
- data/lib/xendify/version.rb +3 -0
- data/lib/xendify.rb +25 -0
- data/xendify.gemspec +34 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 94231b8a9cae2090e114b0d2867af3c6900d28c5b9b9b81883e00a9d68ce474b
|
4
|
+
data.tar.gz: 41f98577d7a2999e8ade5dda54c7f664a2b098139d299ce230e68161031bec81
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3e9de0b6116060686415868a3420bef6ab768af64c5823ce51e09f8863160ad6a0b4b167fdeed0d19574b10a1e4cc6e9378a1e70a031463f661f554538ab9d23
|
7
|
+
data.tar.gz: 5ecee006018315e549ead2827ca5bf75ac00ebfde64905a124b382e4d6b274b3ff0d9f90e23a1b1df865bae2b0fb914493c6d50a486afca6dc145ba34a0ef937
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
xend_it (0.1.0)
|
5
|
+
faraday (~> 1.0)
|
6
|
+
faraday_middleware (~> 1.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
coderay (1.1.3)
|
12
|
+
faraday (1.10.2)
|
13
|
+
faraday-em_http (~> 1.0)
|
14
|
+
faraday-em_synchrony (~> 1.0)
|
15
|
+
faraday-excon (~> 1.1)
|
16
|
+
faraday-httpclient (~> 1.0)
|
17
|
+
faraday-multipart (~> 1.0)
|
18
|
+
faraday-net_http (~> 1.0)
|
19
|
+
faraday-net_http_persistent (~> 1.0)
|
20
|
+
faraday-patron (~> 1.0)
|
21
|
+
faraday-rack (~> 1.0)
|
22
|
+
faraday-retry (~> 1.0)
|
23
|
+
ruby2_keywords (>= 0.0.4)
|
24
|
+
faraday-em_http (1.0.0)
|
25
|
+
faraday-em_synchrony (1.0.0)
|
26
|
+
faraday-excon (1.1.0)
|
27
|
+
faraday-httpclient (1.0.1)
|
28
|
+
faraday-multipart (1.0.4)
|
29
|
+
multipart-post (~> 2)
|
30
|
+
faraday-net_http (1.0.1)
|
31
|
+
faraday-net_http_persistent (1.2.0)
|
32
|
+
faraday-patron (1.0.0)
|
33
|
+
faraday-rack (1.0.0)
|
34
|
+
faraday-retry (1.0.3)
|
35
|
+
faraday_middleware (1.2.0)
|
36
|
+
faraday (~> 1.0)
|
37
|
+
method_source (1.0.0)
|
38
|
+
multipart-post (2.2.3)
|
39
|
+
pry (0.14.1)
|
40
|
+
coderay (~> 1.1)
|
41
|
+
method_source (~> 1.0)
|
42
|
+
rake (13.0.6)
|
43
|
+
ruby2_keywords (0.0.5)
|
44
|
+
|
45
|
+
PLATFORMS
|
46
|
+
x86_64-darwin-21
|
47
|
+
|
48
|
+
DEPENDENCIES
|
49
|
+
pry
|
50
|
+
rake (>= 13.0)
|
51
|
+
xend_it!
|
52
|
+
|
53
|
+
BUNDLED WITH
|
54
|
+
2.3.21
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Xendify
|
2
|
+
class APIResource
|
3
|
+
def initialize(attributes = {})
|
4
|
+
assign_attributes(attributes) if attributes
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def assign_attributes(new_attributes)
|
10
|
+
error_message = "When assigning attributes, you must pass a hash as an argument, #{new_attributes.class} passed."
|
11
|
+
raise ArgumentError, error_message unless new_attributes.respond_to?(:each_pair)
|
12
|
+
return if new_attributes.empty?
|
13
|
+
|
14
|
+
new_attributes.each do |key, value|
|
15
|
+
assign_attribute(key, value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Private: Set attribute with only defined resource attribute
|
20
|
+
def assign_attribute(key, value)
|
21
|
+
setter = :"#{key}="
|
22
|
+
public_send(setter, value) if respond_to?(setter)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/xendify/base.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Xendify
|
2
|
+
class Base
|
3
|
+
attr_reader :client
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def model_name
|
7
|
+
name.sub('Api', 'Model')
|
8
|
+
end
|
9
|
+
|
10
|
+
def model_class
|
11
|
+
Object.const_get(model_name)
|
12
|
+
end
|
13
|
+
|
14
|
+
def allowed_methods
|
15
|
+
@allowed_methods ||= []
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def allow_method(*methods)
|
21
|
+
@allowed_methods = methods
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(client)
|
26
|
+
@client = client
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'faraday_middleware'
|
2
|
+
require 'xendify/middleware'
|
3
|
+
require 'xendify/resources/invoice'
|
4
|
+
|
5
|
+
module Xendify
|
6
|
+
BASE_URL = 'https://api.xendit.co'.freeze
|
7
|
+
|
8
|
+
class Client
|
9
|
+
def initialize(authorization = nil, options = {})
|
10
|
+
@connection = Faraday.new(url: BASE_URL) do |connection|
|
11
|
+
connection.request :basic_auth, authorization, ''
|
12
|
+
connection.request :json
|
13
|
+
connection.response :json
|
14
|
+
|
15
|
+
# logger = find_logger(options[:logger])
|
16
|
+
# if logger
|
17
|
+
# connection.response :logger, logger, { headers: false, bodies: true } do |log|
|
18
|
+
# filtered_logs = options[:filtered_logs]
|
19
|
+
# if filtered_logs.respond_to?(:each)
|
20
|
+
# filtered_logs.each do |filter|
|
21
|
+
# log.filter(%r{(#{filter}=)([\w+-.?@:/]+)}, '\1[FILTERED]')
|
22
|
+
# log.filter(%r{(#{filter}":")([\w+-.?@:/]+)}, '\1[FILTERED]')
|
23
|
+
# log.filter(%r{(#{filter}":)([\w+-.?@:/]+)}, '\1[FILTERED]')
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
connection.use Xendify::Middleware::HandleResponseException
|
29
|
+
connection.adapter Faraday.default_adapter
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def get(url, params = nil)
|
34
|
+
response = @connection.get(url, params)
|
35
|
+
response.body
|
36
|
+
end
|
37
|
+
|
38
|
+
def post(url, params)
|
39
|
+
response = @connection.post(url, params)
|
40
|
+
response.body
|
41
|
+
end
|
42
|
+
|
43
|
+
def invoice
|
44
|
+
@invoice ||= Xendify::Invoice.new(self)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Xendify
|
2
|
+
module Errors
|
3
|
+
module CreditCard
|
4
|
+
class ResponseError < Xendify::Errors::ResponseError; end
|
5
|
+
|
6
|
+
class ChargeError < ResponseError; end
|
7
|
+
|
8
|
+
class CardDeclined < ResponseError
|
9
|
+
def message
|
10
|
+
'The card you are trying to capture has been declined by the issuing bank.'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class ExpiredCard < ResponseError
|
15
|
+
def message
|
16
|
+
'The card you are trying to capture is expired.'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class InsufficientBalance < ResponseError
|
21
|
+
def message
|
22
|
+
'The card you are trying to capture does not have enough balance to complete the capture.'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class StolenCard < ResponseError
|
27
|
+
def message
|
28
|
+
'The card you are trying to capture has been marked as stolen.'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class InactiveCard < ResponseError
|
33
|
+
def message
|
34
|
+
'The card you are trying to capture is inactive.'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class InvalidCvn < ResponseError
|
39
|
+
def message
|
40
|
+
'Invalid CVN number'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Xendify
|
2
|
+
module Errors
|
3
|
+
module Disbursement
|
4
|
+
class Error < Xendify::Errors::ResponseError; end
|
5
|
+
class DescriptionNotFound < Error; end
|
6
|
+
class NotEnoughBalance < Error; end
|
7
|
+
class DuplicateTransactionError < Error; end
|
8
|
+
class RecipientAccountNumberError < Error; end
|
9
|
+
class RecipientAmountError < Error; end
|
10
|
+
class MaximumTransferLimitError < Error; end
|
11
|
+
class BankCodeNotSupported < Error; end
|
12
|
+
class DirectDisbursementNotFound < Error; end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Xendify
|
2
|
+
module Errors
|
3
|
+
module VirtualAccount
|
4
|
+
class ResponseError < Xendify::Errors::ResponseError; end
|
5
|
+
|
6
|
+
class CallbackNotFound < ResponseError; end
|
7
|
+
|
8
|
+
class BankNotSupported < ResponseError; end
|
9
|
+
|
10
|
+
class ApiValidation < ResponseError; end
|
11
|
+
|
12
|
+
class InvalidJsonFormat < ResponseError; end
|
13
|
+
|
14
|
+
class VirtualAccountNumberOutsideRange < ResponseError; end
|
15
|
+
|
16
|
+
class ExpirationDateNotSupported < ResponseError; end
|
17
|
+
|
18
|
+
class ExpirationInvalid < ResponseError; end
|
19
|
+
|
20
|
+
class SuggestedAmountNotSupported < ResponseError; end
|
21
|
+
|
22
|
+
class ExpectedAmountRequired < ResponseError; end
|
23
|
+
|
24
|
+
class MinimumExpectedAmount < ResponseError; end
|
25
|
+
|
26
|
+
class MaximumExpectedAmount < ResponseError; end
|
27
|
+
|
28
|
+
class CallbackVirtualAccountNameNotAllowed < ResponseError; end
|
29
|
+
|
30
|
+
class DescriptionNotSupported < ResponseError; end
|
31
|
+
|
32
|
+
class RequestForbidden < ResponseError; end
|
33
|
+
|
34
|
+
class ClosedVaNotSupported < ResponseError; end
|
35
|
+
|
36
|
+
class DuplicateCallbackVirtualAccount < ResponseError; end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Xendify
|
2
|
+
module Errors
|
3
|
+
class ResponseError < StandardError
|
4
|
+
attr_reader :payload
|
5
|
+
|
6
|
+
def initialize(message = nil, payload = nil)
|
7
|
+
@message = message
|
8
|
+
@payload = payload
|
9
|
+
super(@message) unless @message.nil?
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class ApiValidation < ResponseError; end
|
14
|
+
class UnknownError < ResponseError; end
|
15
|
+
class ServerError < ResponseError; end
|
16
|
+
class DuplicateError < ResponseError; end
|
17
|
+
class DataNotFound < ResponseError; end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module Xendify
|
2
|
+
module Middleware
|
3
|
+
class HandleResponseException < Faraday::Middleware
|
4
|
+
def call(env)
|
5
|
+
@app.call(env).on_complete do |response|
|
6
|
+
raise Xendify::Errors::ServerError, 'An unexpected error occurred, our team has been notified and will troubleshoot the issue.' if response.status.to_s.start_with?('5')
|
7
|
+
|
8
|
+
validate_response(response.body)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/MethodLength
|
15
|
+
def validate_response(response)
|
16
|
+
return true if response.nil?
|
17
|
+
|
18
|
+
json_response = JSON.parse(response)
|
19
|
+
json_response = json_response.first if json_response.is_a? Array
|
20
|
+
|
21
|
+
return true if json_response.nil?
|
22
|
+
return true if json_response['error_code'].nil?
|
23
|
+
|
24
|
+
error_message = json_response['message']
|
25
|
+
|
26
|
+
case json_response['error_code']
|
27
|
+
when 'USER_DID_NOT_AUTHORIZE_THE_PAYMENT'
|
28
|
+
raise Xendify::Errors::OVO::PaymentTimeout.new(error_message, json_response)
|
29
|
+
when 'DUPLICATE_PAYMENT'
|
30
|
+
raise Xendify::Errors::OVO::DuplicatePayment.new(error_message, json_response)
|
31
|
+
when 'SENDING_TRANSACTION_ERROR'
|
32
|
+
raise Xendify::Errors::OVO::SendingRequest.new(error_message, json_response)
|
33
|
+
when 'USER_DECLINED_THE_TRANSACTION'
|
34
|
+
raise Xendify::Errors::OVO::TransactionDeclined.new(error_message, json_response)
|
35
|
+
when 'PHONE_NUMBER_NOT_REGISTERED'
|
36
|
+
raise Xendify::Errors::OVO::PhoneNumberNotRegistered.new(error_message, json_response)
|
37
|
+
when 'EWALLET_APP_UNREACHABLE'
|
38
|
+
raise Xendify::Errors::OVO::EwalletAppUnreacable.new(error_message, json_response)
|
39
|
+
when 'EXTERNAL_ERROR'
|
40
|
+
raise Xendify::Errors::OVO::ExternalError.new(error_message, json_response)
|
41
|
+
when 'PAYMENT_NOT_FOUND_ERROR'
|
42
|
+
raise Xendify::Errors::OVO::PaymentNotFound.new(error_message, json_response)
|
43
|
+
when 'CHANNEL_NOT_ACTIVATED'
|
44
|
+
raise Xendify::Errors::V1::Ewallet::ChannelNotActivated.new(error_message, json_response)
|
45
|
+
when 'DUPLICATE_ERROR'
|
46
|
+
raise Xendify::Errors::DuplicateError.new(error_message, json_response)
|
47
|
+
when 'DATA_NOT_FOUND'
|
48
|
+
raise Xendify::Errors::DataNotFound.new(error_message, json_response)
|
49
|
+
when 'API_VALIDATION_ERROR'
|
50
|
+
# In this exception with custom the title since, the message from
|
51
|
+
# could returns arrays (see the payload for the full messages)
|
52
|
+
raise Xendify::Errors::ApiValidation.new('Validation error', json_response)
|
53
|
+
when 'CALLBACK_VIRTUAL_ACCOUNT_NOT_FOUND_ERROR'
|
54
|
+
raise Xendify::Errors::VirtualAccount::CallbackNotFound.new(error_message, json_response)
|
55
|
+
when 'BANK_NOT_SUPPORTED_ERROR'
|
56
|
+
raise Xendify::Errors::VirtualAccount::BankNotSupported.new(error_message, json_response)
|
57
|
+
when 'INVALID_JSON_FORMAT'
|
58
|
+
raise Xendify::Errors::VirtualAccount::InvalidJsonFormat.new(error_message, json_response)
|
59
|
+
when 'VIRTUAL_ACCOUNT_NUMBER_OUTSIDE_RANGE'
|
60
|
+
raise Xendify::Errors::VirtualAccount::VirtualAccountNumberOutsideRange.new(error_message, json_response)
|
61
|
+
when 'EXPIRATION_DATE_NOT_SUPPORTED_ERROR'
|
62
|
+
raise Xendify::Errors::VirtualAccount::ExpirationDateNotSupported.new(error_message, json_response)
|
63
|
+
when 'EXPIRATION_DATE_INVALID_ERROR'
|
64
|
+
raise Xendify::Errors::VirtualAccount::ExpirationInvalid.new(error_message, json_response)
|
65
|
+
when 'SUGGESTED_AMOUNT_NOT_SUPPORTED_ERROR'
|
66
|
+
raise Xendify::Errors::VirtualAccount::SuggestedAmountNotSupported.new(error_message, json_response)
|
67
|
+
when 'EXPECTED_AMOUNT_REQUIRED_ERROR'
|
68
|
+
raise Xendify::Errors::VirtualAccount::ExpectedAmountRequired.new(error_message, json_response)
|
69
|
+
when 'CLOSED_VA_NOT_SUPPORTED_ERROR'
|
70
|
+
raise Xendify::Errors::VirtualAccount::ClosedVaNotSupported.new(error_message, json_response)
|
71
|
+
when 'DUPLICATE_CALLBACK_VIRTUAL_ACCOUNT_ERROR'
|
72
|
+
raise Xendify::Errors::VirtualAccount::DuplicateCallbackVirtualAccount.new(error_message, json_response)
|
73
|
+
when 'MAXIMUM_EXPECTED_AMOUNT_ERROR'
|
74
|
+
raise Xendify::Errors::VirtualAccount::MaximumExpectedAmount.new(error_message, json_response)
|
75
|
+
when 'CALLBACK_VIRTUAL_ACCOUNT_NAME_NOT_ALLOWED_ERROR'
|
76
|
+
raise Xendify::Errors::VirtualAccount::CallbackVirtualAccountNameNotAllowed.new(error_message, json_response)
|
77
|
+
when 'DESCRIPTION_NOT_SUPPORTED_ERROR'
|
78
|
+
raise Xendify::Errors::VirtualAccount::DescriptionNotSupported.new(error_message, json_response)
|
79
|
+
when 'MINIMUM_EXPECTED_AMOUNT_ERROR'
|
80
|
+
raise Xendify::Errors::VirtualAccount::MinimumExpectedAmount.new(error_message, json_response)
|
81
|
+
when 'REQUEST_FORBIDDEN_ERROR'
|
82
|
+
raise Xendify::Errors::VirtualAccount::RequestForbidden.new(error_message, json_response)
|
83
|
+
# credit cards
|
84
|
+
when 'INVALID_TOKEN_ID_ERROR'
|
85
|
+
raise Xendify::Errors::CreditCard::ChargeError.new(error_message, json_response)
|
86
|
+
# disbursements
|
87
|
+
when 'DISBURSEMENT_DESCRIPTION_NOT_FOUND_ERROR'
|
88
|
+
raise Xendify::Errors::Disbursement::DescriptionNotFound.new(error_message, json_response)
|
89
|
+
when 'DIRECT_DISBURSEMENT_BALANCE_INSUFFICIENT_ERROR'
|
90
|
+
raise Xendify::Errors::Disbursement::NotEnoughBalance.new(error_message, json_response)
|
91
|
+
when 'DIRECT_DISBURSEMENT_NOT_FOUND_ERROR'
|
92
|
+
raise Xendify::Errors::Disbursement::DirectDisbursementNotFound.new(error_message, json_response)
|
93
|
+
when 'DUPLICATE_TRANSACTION_ERROR'
|
94
|
+
raise Xendify::Errors::Disbursement::DuplicateTransactionError.new(error_message, json_response)
|
95
|
+
when 'RECIPIENT_ACCOUNT_NUMBER_ERROR'
|
96
|
+
raise Xendify::Errors::Disbursement::RecipientAccountNumberError.new(error_message, json_response)
|
97
|
+
when 'RECIPIENT_AMOUNT_ERROR'
|
98
|
+
raise Xendify::Errors::Disbursement::RecipientAmountError.new(error_message, json_response)
|
99
|
+
when 'MAXIMUM_TRANSFER_LIMIT_ERROR'
|
100
|
+
raise Xendify::Errors::Disbursement::MaximumTransferLimitError.new(error_message, json_response)
|
101
|
+
when 'BANK_CODE_NOT_SUPPORTED_ERROR'
|
102
|
+
raise Xendify::Errors::Disbursement::BankCodeNotSupported.new(error_message, json_response)
|
103
|
+
when 'SERVER_ERROR'
|
104
|
+
raise Xendify::Errors::ServerError.new(error_message, json_response)
|
105
|
+
else
|
106
|
+
raise Xendify::Errors::UnknownError.new(error_message, json_response)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/MethodLength
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'xendify/base'
|
2
|
+
require 'xendify/api_resource'
|
3
|
+
require 'xendify/resources/invoice'
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
module Xendify
|
7
|
+
POST_PATH = '/v2/invoices'.freeze
|
8
|
+
GET_PATH = '/v2/invoices'.freeze
|
9
|
+
|
10
|
+
class InvoiceModel < APIResource
|
11
|
+
attr_accessor :id,
|
12
|
+
:user_id,
|
13
|
+
:external_id,
|
14
|
+
:status,
|
15
|
+
:merchant_name,
|
16
|
+
:merchant_profile_picture_url,
|
17
|
+
:amount,
|
18
|
+
:payer_email,
|
19
|
+
:description,
|
20
|
+
:invoice_url,
|
21
|
+
:expiry_date,
|
22
|
+
:available_banks,
|
23
|
+
:available_retail_outlets,
|
24
|
+
:should_exclude_credit_card,
|
25
|
+
:should_send_email,
|
26
|
+
:created,
|
27
|
+
:updated,
|
28
|
+
:mid_label,
|
29
|
+
:currency,
|
30
|
+
:fixed_va,
|
31
|
+
:items,
|
32
|
+
:fees
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
class Invoice < Base
|
37
|
+
def get(id:)
|
38
|
+
response = client.get("#{GET_PATH}/#{id}")
|
39
|
+
Xendify::InvoiceModel.new(response)
|
40
|
+
end
|
41
|
+
|
42
|
+
def post(params:)
|
43
|
+
response = client.post(POST_PATH, params)
|
44
|
+
Xendify::InvoiceModel.new(response)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/xendify.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'xendify/version'
|
4
|
+
require 'xendify/client'
|
5
|
+
|
6
|
+
# require errors
|
7
|
+
require 'xendify/errors'
|
8
|
+
require 'xendify/errors/disbursement'
|
9
|
+
require 'xendify/errors/credit_card'
|
10
|
+
require 'xendify/errors/virtual_account'
|
11
|
+
|
12
|
+
module Xendify
|
13
|
+
class << self
|
14
|
+
attr_accessor :configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.configure
|
18
|
+
self.configuration ||= Configuration.new
|
19
|
+
yield(configuration)
|
20
|
+
end
|
21
|
+
|
22
|
+
class Configuration
|
23
|
+
attr_accessor :logger
|
24
|
+
end
|
25
|
+
end
|
data/xendify.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(::File.join(::File.dirname(__FILE__), "lib"))
|
4
|
+
|
5
|
+
require "xendify/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "xendify"
|
9
|
+
s.version = Xendify::VERSION
|
10
|
+
s.required_ruby_version = ">= 2.3.0"
|
11
|
+
s.summary = "Xen wrapper"
|
12
|
+
s.description = "Handle xen API with ease."
|
13
|
+
s.authors = ["calmhacker"]
|
14
|
+
s.email = "be@calmhacker.com"
|
15
|
+
ignored = Regexp.union(
|
16
|
+
/\A\.editorconfig/,
|
17
|
+
/\A\.git/,
|
18
|
+
/\A\.rubocop/,
|
19
|
+
/\A\.travis.yml/,
|
20
|
+
/\A\.vscode/,
|
21
|
+
/\Atest/
|
22
|
+
)
|
23
|
+
|
24
|
+
s.files = `git ls-files`.split("\n").reject { |f| ignored.match(f) }
|
25
|
+
s.executables = `git ls-files -- bin/*`.split("\n")
|
26
|
+
.map { |f| ::File.basename(f) }
|
27
|
+
s.require_paths = ["lib"]
|
28
|
+
|
29
|
+
s.homepage = "https://rubygems.org/gems/xendit"
|
30
|
+
s.license = "MIT"
|
31
|
+
|
32
|
+
s.add_dependency 'faraday', '~> 1.0'
|
33
|
+
s.add_dependency 'faraday_middleware', '~> 1.0'
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xendify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- calmhacker
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-12-03 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: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
description: Handle xen API with ease.
|
42
|
+
email: be@calmhacker.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- Gemfile
|
48
|
+
- Gemfile.lock
|
49
|
+
- lib/xendify.rb
|
50
|
+
- lib/xendify/api_resource.rb
|
51
|
+
- lib/xendify/base.rb
|
52
|
+
- lib/xendify/client.rb
|
53
|
+
- lib/xendify/errors.rb
|
54
|
+
- lib/xendify/errors/credit_card.rb
|
55
|
+
- lib/xendify/errors/disbursement.rb
|
56
|
+
- lib/xendify/errors/invoice.rb
|
57
|
+
- lib/xendify/errors/virtual_account.rb
|
58
|
+
- lib/xendify/middleware.rb
|
59
|
+
- lib/xendify/resources/invoice.rb
|
60
|
+
- lib/xendify/version.rb
|
61
|
+
- xendify.gemspec
|
62
|
+
homepage: https://rubygems.org/gems/xendit
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 2.3.0
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubygems_version: 3.3.7
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Xen wrapper
|
85
|
+
test_files: []
|