-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95e4e9b
commit 210b93b
Showing
7 changed files
with
119 additions
and
11 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 |
---|---|---|
|
@@ -12,4 +12,4 @@ pkg/ | |
.DS_Store | ||
.idea/ | ||
Gemfile.lock | ||
tmp/ | ||
tmp/ |
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
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 |
---|---|---|
@@ -1,22 +1,62 @@ | ||
require "xeroizer/models/payment_service" | ||
|
||
module Xeroizer | ||
module Record | ||
|
||
class BrandingThemeModel < BaseModel | ||
|
||
set_permissions :read | ||
|
||
|
||
set_permissions :read, :write | ||
|
||
public | ||
|
||
def payment_services(id) | ||
@payment_services ||= @application.http_get(@application.client, payment_services_endpoint(id)) | ||
end | ||
|
||
def add_payment_service(id:,payment_service_id:) | ||
xml = { | ||
PaymentService: { | ||
PaymentServiceID: payment_service_id | ||
} | ||
}.to_xml | ||
|
||
@application.http_post(@application.client, payment_services_endpoint(id), xml) | ||
end | ||
|
||
private | ||
|
||
def payment_services_endpoint(id) | ||
"#{url}/#{id}/PaymentServices" | ||
end | ||
|
||
end | ||
|
||
class BrandingTheme < Base | ||
|
||
set_primary_key :branding_theme_id | ||
|
||
guid :branding_theme_id | ||
string :name | ||
integer :sort_order | ||
datetime_utc :created_date_utc, :api_name => 'CreatedDateUTC' | ||
|
||
# Unfortunately, this part of the API does not work the same as the rest. | ||
# You cannot POST child records to Branding Themes. | ||
# | ||
# The endpoints are: | ||
# GET /BrandingThemes/{BrandingThemeID}/PaymentServices | ||
# POST /BrandingThemes/{BrandingThemeID}/PaymentServices | ||
# | ||
# has_one :payment_service, :model_name => 'PaymentService', :list_complete => true | ||
|
||
def payment_services | ||
parent.payment_services(id) | ||
end | ||
|
||
def add_payment_service(payment_service_id) | ||
parent.add_payment_service(id: id, payment_service_id: payment_service_id) | ||
end | ||
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,22 @@ | ||
module Xeroizer | ||
module Record | ||
|
||
class PaymentServiceModel < BaseModel | ||
|
||
set_permissions :read, :write, :update | ||
|
||
end | ||
|
||
class PaymentService < Base | ||
|
||
set_primary_key :payment_service_id | ||
|
||
guid :payment_service_id | ||
string :payment_service_name | ||
string :payment_service_url | ||
string :payment_service_type | ||
string :pay_now_text | ||
|
||
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,15 @@ | ||
<Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
<Id>42d8b00c-2fdd-4a8a-9b84-82cfe78ff34a</Id> | ||
<Status>OK</Status> | ||
<ProviderName>Test Provider Name</ProviderName> | ||
<DateTimeUTC>2018-06-18T04:13:44.7828584Z</DateTimeUTC> | ||
<PaymentServices> | ||
<PaymentService> | ||
<PaymentServiceID>4d7f4335-6f16-437a-86e3-a856ebc576b8</PaymentServiceID> | ||
<PaymentServiceName>Custom Service</PaymentServiceName> | ||
<PaymentServiceType>Custom</PaymentServiceType> | ||
<PaymentServiceUrl>http://example.com</PaymentServiceUrl> | ||
<PayNowText>Pay Me</PayNowText> | ||
</PaymentService> | ||
</PaymentServices> | ||
</Response> |
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,29 @@ | ||
require 'test_helper' | ||
|
||
class PaymentServiceTest < Test::Unit::TestCase | ||
include TestHelper | ||
|
||
def setup | ||
@client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET) | ||
end | ||
|
||
context "response parsing" do | ||
it "parses default attributes" do | ||
@instance = Xeroizer::Record::PaymentServiceModel.new(nil, "PaymentService") | ||
|
||
some_xml = get_record_xml("payment_service") | ||
|
||
result = @instance.parse_response(some_xml) | ||
payment_service = result.response_items.first | ||
|
||
keys = [:payment_service_id, | ||
:payment_service_name, | ||
:payment_service_type, | ||
:payment_service_url, | ||
:pay_now_text | ||
] | ||
|
||
assert_equal(payment_service.attributes.keys, keys) | ||
end | ||
end | ||
end |