-
Notifications
You must be signed in to change notification settings - Fork 7
[DASH-1635] Expose Apple Pay (web) domain registration logic #41
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
Merged
radar
merged 3 commits into
fatzebra:master
from
AV-room:task/dash-1635-fatzebra-gem-applepay-utilities
Mar 4, 2024
Merged
Changes from all commits
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 hidden or 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 hidden or 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,48 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module FatZebra | ||
| module Utilities | ||
| module ApplePay | ||
| class Domain < APIResource | ||
|
|
||
| ENDPOINT_URL = '/v1.0/utilities/apple_pay/domains' | ||
|
|
||
| class << self | ||
|
|
||
| ## | ||
| # Register an Apple Pay (web) domain | ||
| # | ||
| # @return [FatZebra::Utilities::ApplePay::Domains] response | ||
| def register!(domain, params = {}) | ||
| response = request(:post, path(domain), params) | ||
| initialize_from(response) | ||
| end | ||
|
|
||
| ## | ||
| # Check registration status of an Apple Pay (web) domain | ||
| # | ||
| # @return [FatZebra::Utilities::ApplePay::Domains] response | ||
| def find!(domain) | ||
| response = request(:get, path(domain)) | ||
| initialize_from(response) | ||
| end | ||
|
|
||
| ## | ||
| # Delete an Apple Pay (web) domain | ||
| # | ||
| # @return [FatZebra::Utilities::ApplePay::Domains] response | ||
| def delete!(domain) | ||
| response = request(:delete, path(domain)) | ||
| initialize_from(response) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def path(domain) | ||
| "#{ENDPOINT_URL}/#{domain}" | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
52 changes: 52 additions & 0 deletions
52
spec/cassettes/FatZebra_Utilities_ApplePay_Domain/_delete_/deletes_the_domain.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
86 changes: 86 additions & 0 deletions
86
spec/cassettes/FatZebra_Utilities_ApplePay_Domain/_find_/fetches_the_domain.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
spec/cassettes/FatZebra_Utilities_ApplePay_Domain/_register_/creates_the_domain.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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,39 @@ | ||
| require 'spec_helper' | ||
|
|
||
| describe FatZebra::Utilities::ApplePay::Domain do | ||
|
|
||
| describe '.register!', :vcr do | ||
| subject(:create) { FatZebra::Utilities::ApplePay::Domain.register!(domain, valid_payload) } | ||
|
|
||
| let!(:domain) { "www.example99.com" } | ||
| let!(:valid_payload) {{ | ||
| async: false | ||
| }} | ||
|
|
||
| it "creates the domain" do | ||
| expect(create).to be_accepted | ||
| expect(create.domain).to eq(domain) | ||
| expect(create.status).to eq("Active") | ||
| end | ||
| end | ||
|
|
||
| describe '.find!', :vcr do | ||
| subject(:find) { FatZebra::Utilities::ApplePay::Domain.find!(domain) } | ||
| let!(:domain) { "www.example.com" } | ||
|
|
||
| it "fetches the domain" do | ||
| expect(find).to be_accepted | ||
| expect(find.domain).to eq(domain) | ||
| expect(find.status).to eq("Active") | ||
| end | ||
| end | ||
|
|
||
| describe '.delete!', :vcr do | ||
| subject(:delete) { FatZebra::Utilities::ApplePay::Domain.delete!(domain) } | ||
| let!(:domain) { "www.example99.com" } | ||
|
|
||
| it "deletes the domain" do | ||
| expect(delete).to be_accepted | ||
| 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.
The gateway endpoints don't seem to validate the given domain in any way. Should I add that validation here?
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.
Apple will happily decline any invalid value