Created
December 19, 2015 01:51
-
-
Save RajeshReddyM/046572a839603dbd15e8 to your computer and use it in GitHub Desktop.
Code Review Ruby
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 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