Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/fat_zebra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
require 'fat_zebra/web_hook'
require 'fat_zebra/batch'

# Utilities/Mastercard
# Utilities
require 'fat_zebra/utilities/apple_pay/domain'
require 'fat_zebra/utilities/mastercard/click_to_pay/registration'

# Paypal API Resources
Expand Down
48 changes: 48 additions & 0 deletions lib/fat_zebra/utilities/apple_pay/domain.rb
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)
Copy link
Author

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?

Copy link
Contributor

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

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions spec/lib/fat_zebra/utilities/apple_pay/domain_spec.rb
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