-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
559 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
primary_balance = Mollie::Balance.primary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
balance = Mollie::Balance.get("bal_gVMhHKqSSRYJyPsuoPNFH") | ||
report = balance.report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
balance = Mollie::Balance.get("bal_gVMhHKqSSRYJyPsuoPNFH") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
balance = Mollie::Balance.get("bal_gVMhHKqSSRYJyPsuoPNFH") | ||
transactions = balance.transactions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
balances = Mollie::Balance.all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
module Mollie | ||
class Balance < Base | ||
attr_accessor :id, | ||
:mode, | ||
:currency, | ||
:description, | ||
:status, | ||
:transfer_frequency, | ||
:transfer_reference, | ||
:_links | ||
|
||
attr_reader :transfer_threshold, | ||
:transfer_destination, | ||
:available_amount, | ||
:pending_amount, | ||
:created_at | ||
|
||
alias links _links | ||
|
||
def self.primary(options = {}) | ||
get('primary', options) | ||
end | ||
|
||
def transfer_threshold=(amount) | ||
@transfer_threshold = Mollie::Amount.new(amount) | ||
end | ||
|
||
def transfer_destination=(transfer_destination) | ||
@transfer_destination = OpenStruct.new(transfer_destination) if transfer_destination.is_a?(Hash) | ||
end | ||
|
||
def available_amount=(amount) | ||
@available_amount = Mollie::Amount.new(amount) | ||
end | ||
|
||
def pending_amount=(amount) | ||
@pending_amount = Mollie::Amount.new(amount) | ||
end | ||
|
||
def created_at=(created_at) | ||
@created_at = Time.parse(created_at.to_s) | ||
end | ||
|
||
def report(options = {}) | ||
response = Client.instance.perform_http_call("GET", "balances/#{id}", "report", {}, options) | ||
Balance::Report.new(response) | ||
end | ||
|
||
def transactions(options = {}) | ||
Balance::Transaction.all(options.merge(balance_id: id)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Mollie | ||
class Balance | ||
class Report < Base | ||
attr_accessor :balance_id, | ||
:time_zone, | ||
:grouping, | ||
:totals, | ||
:_links | ||
|
||
attr_reader :from, | ||
:until | ||
|
||
alias links _links | ||
|
||
def from=(from) | ||
@from = Date.parse(from) | ||
end | ||
|
||
def until=(until_date) | ||
# `until` is a reserved keyword | ||
@until = Date.parse(until_date) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module Mollie | ||
class Balance | ||
class Transaction < Base | ||
attr_accessor :id, | ||
:type, | ||
:_links | ||
|
||
attr_reader :result_amount, | ||
:initial_amount, | ||
:deductions, | ||
:context, | ||
:created_at | ||
|
||
alias links _links | ||
|
||
def self.embedded_resource_name | ||
"balance_transactions" | ||
end | ||
|
||
def result_amount=(amount) | ||
@result_amount = Mollie::Amount.new(amount) | ||
end | ||
|
||
def initial_amount=(amount) | ||
@initial_amount = Mollie::Amount.new(amount) | ||
end | ||
|
||
def deductions=(amount) | ||
@deductions = Mollie::Amount.new(amount) | ||
end | ||
|
||
def context=(context) | ||
@context = OpenStruct.new(context) if context.is_a?(Hash) | ||
end | ||
|
||
def created_at=(created_at) | ||
@created_at = Time.parse(created_at.to_s) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"resource": "balance", | ||
"id": "bal_gVMhHKqSSRYJyPsuoPNFH", | ||
"mode": "live", | ||
"currency": "EUR", | ||
"description": "Primary balance", | ||
"availableAmount": { | ||
"currency": "EUR", | ||
"value": "905.25" | ||
}, | ||
"pendingAmount": { | ||
"currency": "EUR", | ||
"value": "0.00" | ||
}, | ||
"transferFrequency": "twice-a-month", | ||
"transferThreshold": { | ||
"currency": "EUR", | ||
"value": "5.00" | ||
}, | ||
"transferReference": "Mollie settlement", | ||
"transferDestination": { | ||
"type": "bank-account", | ||
"beneficiaryName": "John Doe", | ||
"bankAccount": "NL55INGB0000000000" | ||
}, | ||
"status": "active", | ||
"createdAt": "2019-01-10T12:06:28+00:00", | ||
"_links": { | ||
"self": { | ||
"href": "https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH", | ||
"type": "application/hal+json" | ||
}, | ||
"documentation": { | ||
"href": "https://docs.mollie.com/reference/get-balance", | ||
"type": "text/html" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"count": 1, | ||
"_embedded": { | ||
"balances": [ | ||
{ | ||
"resource": "balance", | ||
"id": "bal_one" | ||
}, | ||
{ | ||
"resource": "balance", | ||
"id": "bal_two" | ||
}, | ||
{ | ||
"resource": "balance", | ||
"id": "bal_three" | ||
} | ||
] | ||
}, | ||
"_links": { | ||
"documentation": { | ||
"href": "https://docs.mollie.com/reference/v2/balances-api/list-balances", | ||
"type": "text/html" | ||
}, | ||
"self": { | ||
"href": "https://api.mollie.com/v2/balances?limit=5", | ||
"type": "application/hal+json" | ||
}, | ||
"previous": null, | ||
"next": { | ||
"href": "https://api.mollie.com/v2/balances?from=bal_gVMhHKqSSRYJyPsuoPABC&limit=5", | ||
"type": "application/hal+json" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"count": 2, | ||
"_embedded": { | ||
"balance_transactions": [ | ||
{ | ||
"resource": "balance_transaction", | ||
"id": "baltr_QM24QwzUWR4ev4Xfgyt29A", | ||
"type": "refund", | ||
"resultAmount": { | ||
"currency": "EUR", | ||
"value": "-10.25" | ||
}, | ||
"initialAmount": { | ||
"currency": "EUR", | ||
"value": "-10.00" | ||
}, | ||
"deductions": { | ||
"currency": "EUR", | ||
"value": "-0.25" | ||
}, | ||
"context": { | ||
"paymentId": "tr_7UhSN1zuXS", | ||
"refundId": "re_4qqhO89gsT" | ||
}, | ||
"createdAt": "2021-01-10T12:06:28+00:00" | ||
}, | ||
{ | ||
"resource": "balance_transaction", | ||
"id": "baltr_WhmDwNYR87FPDbiwBhUXCh", | ||
"type": "payment", | ||
"resultAmount": { | ||
"currency": "EUR", | ||
"value": "9.71" | ||
}, | ||
"initialAmount": { | ||
"currency": "EUR", | ||
"value": "10.00" | ||
}, | ||
"deductions": { | ||
"currency": "EUR", | ||
"value": "-0.29" | ||
}, | ||
"context": { | ||
"paymentId": "tr_7UhSN1zuXS" | ||
}, | ||
"createdAt": "2021-01-10T12:06:28+00:00" | ||
} | ||
] | ||
}, | ||
"_links": { | ||
"self": { | ||
"href": "...", | ||
"type": "application/hal+json" | ||
}, | ||
"previous": null, | ||
"next": { | ||
"href": "https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH/transactions?from=baltr_rXeW2yPqqDUyfAqq8fS5Bg&limit=5", | ||
"type": "application/hal+json" | ||
}, | ||
"documentation": { | ||
"href": "...", | ||
"type": "text/html" | ||
} | ||
} | ||
} |
Oops, something went wrong.