Skip to content

Instantly share code, notes, and snippets.

@RajeshReddyM
Created December 19, 2015 01:51
Show Gist options
  • Select an option

  • Save RajeshReddyM/046572a839603dbd15e8 to your computer and use it in GitHub Desktop.

Select an option

Save RajeshReddyM/046572a839603dbd15e8 to your computer and use it in GitHub Desktop.
Code Review Ruby
class ShopifyAPIClient
attr_reader :shop_id
SECRET_API_KEY = ENV[SECRET_API_KEY]
def initialize(shop_Id)
@shop_id = shop_Id
end
def shop_id
@shop_id
end
["orders", "products"].each do |action|
define_method("#{action}") do |argument|
params = Hash.new
params[:basic_auth] = {username: SECRET_API_KEY, password: ''}
orders_json = some_http_library.get("https://www.shopify.this.is.a.sample.com/#{shop_id}/#{action}", params)
return JSON.parse(orders_json)
end
end
def product(id)
params = Hash.new
params[:basic_auth] = {username: SECRET_API_KEY, password: ''}
product_json = some_http_library.get("https://www.shopify.this.is.a.sample.com/#{shop_id}/products/#{id}", params)
return JSON.parse(product_json)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment