Skip to content

Instantly share code, notes, and snippets.

@jordanhudgens
Created November 16, 2018 14:25
Show Gist options
  • Save jordanhudgens/3f3e9c9a90eab6cc948a061efe3ac06f to your computer and use it in GitHub Desktop.
Save jordanhudgens/3f3e9c9a90eab6cc948a061efe3ac06f to your computer and use it in GitHub Desktop.
class SalesService
def initialize(product, full_name, email, shop_hacker_merchant_id)
@options = {
sale: {
shop_hacker_product_id: product.shop_hacker_product_id,
customer_full_name: full_name,
customer_email: email,
merchant_id: shop_hacker_merchant_id
}
}
end
def auth
{
username: ENV.fetch('SHOP_HACKER_API_KEY'),
password: ENV.fetch('SHOP_HACKER_SECRET')
}
end
def create_sale
HTTParty.post("https://api.shophacker.com/sales", body: @options, basic_auth: auth)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment