diff --git a/CHANGELOG.md b/CHANGELOG.md index daa552e..40997e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. + +#### v1.3.0 - 2016-04-14 + - Added Mandates API. + - Added `recurringType` and `mandateId` to Payments API. + #### v1.2.2 - 2016-03-21 - The members `customers` and `customers_payments` weren't made public within `attr_reader` ([#21](https://github.com/mollie/mollie-api-ruby/pull/21)). - Updated the bundled CA's cacert.pem file to date `Jan 20, 2016`. diff --git a/lib/Mollie/API/Client.rb b/lib/Mollie/API/Client.rb index 38df50e..0f005ed 100644 --- a/lib/Mollie/API/Client.rb +++ b/lib/Mollie/API/Client.rb @@ -6,6 +6,7 @@ "Resource/Base", "Resource/Customers", "Resource/Customers/Payments", +"Resource/Customers/Mandates", "Resource/Payments", "Resource/Payments/Refunds", "Resource/Issuers", @@ -13,6 +14,7 @@ "Object/Base", "Object/List", "Object/Customer", +"Object/Mandate", "Object/Payment", "Object/Payment/Refund", "Object/Issuer", @@ -24,7 +26,7 @@ class Client API_ENDPOINT = "https://api.mollie.nl" API_VERSION = "v1" - attr_reader :payments, :issuers, :methods, :payments_refunds, :customers, :customers_payments + attr_reader :payments, :issuers, :methods, :payments_refunds, :customers, :customers_payments, :customers_mandates def initialize @payments = Mollie::API::Resource::Payments.new self @@ -33,6 +35,7 @@ def initialize @payments_refunds = Mollie::API::Resource::Payments::Refunds.new self @customers = Mollie::API::Resource::Customers.new self @customers_payments = Mollie::API::Resource::Customers::Payments.new self + @customers_mandates = Mollie::API::Resource::Customers::Mandates.new self @api_endpoint = API_ENDPOINT @api_key = "" diff --git a/lib/Mollie/API/Client/Version.rb b/lib/Mollie/API/Client/Version.rb index b4bb2ee..a056578 100644 --- a/lib/Mollie/API/Client/Version.rb +++ b/lib/Mollie/API/Client/Version.rb @@ -1,7 +1,7 @@ module Mollie module API class Client - CLIENT_VERSION = "1.2.2" + CLIENT_VERSION = "1.3.0" end end end diff --git a/lib/Mollie/API/Object/Mandate.rb b/lib/Mollie/API/Object/Mandate.rb new file mode 100644 index 0000000..8533c65 --- /dev/null +++ b/lib/Mollie/API/Object/Mandate.rb @@ -0,0 +1,22 @@ +module Mollie + module API + module Object + class Mandate < Base + STATUS_VALID = "valid" + STATUS_INVALID = "invalid" + + attr_accessor :resource, + :id, + :status, + :method, + :customerId, + :details, + :createdDatetime + + def valid? + @status == STATUS_VALID + end + end + end + end +end diff --git a/lib/Mollie/API/Object/Payment.rb b/lib/Mollie/API/Object/Payment.rb index dd5005f..affb410 100644 --- a/lib/Mollie/API/Object/Payment.rb +++ b/lib/Mollie/API/Object/Payment.rb @@ -7,6 +7,11 @@ class Payment < Base STATUS_EXPIRED = "expired" STATUS_PAID = "paid" STATUS_PAIDOUT = "paidout" + STATUS_FAILED = "failed" + + RECURRINGTYPE_NONE = nil + RECURRINGTYPE_FIRST = "first" + RECURRINGTYPE_RECURRING = "recurring" attr_accessor :id, :status, @@ -18,6 +23,10 @@ class Payment < Base :paidDatetime, :expiredDatetime, :cancelledDatetime, + :customerId, + :recurringType, + :mandateId, + :settlementId, :metadata, :details, :links diff --git a/lib/Mollie/API/Resource/Customers/Mandates.rb b/lib/Mollie/API/Resource/Customers/Mandates.rb new file mode 100644 index 0000000..6cb22db --- /dev/null +++ b/lib/Mollie/API/Resource/Customers/Mandates.rb @@ -0,0 +1,27 @@ +require 'open-uri' + +module Mollie + module API + module Resource + class Customers + class Mandates < Base + @customer_id = nil + + def getResourceObject + Mollie::API::Object::Mandate + end + + def getResourceName + customer_id = URI::encode(@customer_id) + "customers/#{customer_id}/mandates" + end + + def with(customer) + @customer_id = customer.id + self + end + end + end + end + end +end