Created
November 16, 2018 14:25
-
-
Save jordanhudgens/3f3e9c9a90eab6cc948a061efe3ac06f to your computer and use it in GitHub Desktop.
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
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