-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Payment services #439
Merged
Merged
Payment services #439
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 | ||
CloCkWeRX marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CloCkWeRX could you give me an example of proper formatting for named params please. Would this suffice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure would :)