Class: Yotpo::Client
- Inherits:
-
Object
- Object
- Yotpo::Client
- Defined in:
- lib/yotpo/client.rb
Instance Method Summary collapse
-
#delete(url) ⇒ Object
Does a DELETE request to the url with the params.
-
#get(url, params = {}) ⇒ Object
Does a GET request to the url with the params.
-
#in_parallel ⇒ Object
Does a parallel request to the api for all of the requests in the block.
-
#initialize(url = 'https://api.yotpo.com', parallel_requests = 5) ⇒ Client
constructor
Creates a new instance of Yotpo::Client.
-
#post(url, params) ⇒ Object
Does a POST request to the url with the params.
-
#put(url, params) ⇒ Object
Does a PUT request to the url with the params.
Methods included from Purchase
#create_new_purchase, #create_new_purchases, #get_purchases
Methods included from User
#create_user, #get_login_url, #get_oauth_token
Methods included from Review
#create_review, #get_product_reviews
Methods included from Reminder
Methods included from Product
#get_all_bottom_lines, #get_product_bottom_line
Methods included from AccountPlatform
Methods included from Account
#check_minisite_subdomain, #update_account
Constructor Details
#initialize(url = 'https://api.yotpo.com', parallel_requests = 5) ⇒ Client
Creates a new instance of Yotpo::Client
33 34 35 36 |
# File 'lib/yotpo/client.rb', line 33 def initialize(url = 'https://api.yotpo.com', parallel_requests = 5) @url = url @parallel_requests = parallel_requests end |
Instance Method Details
#delete(url) ⇒ Object
Does a DELETE request to the url with the params
78 79 80 81 82 |
# File 'lib/yotpo/client.rb', line 78 def delete(url) preform(url, :delete) do return connection.delete(url) end end |
#get(url, params = {}) ⇒ Object
Does a GET request to the url with the params
43 44 45 46 47 48 |
# File 'lib/yotpo/client.rb', line 43 def get(url, params = {}) params = params.inject({}){|memo,(k,v)| memo[k.to_s] = v; memo} preform(url, :get, params: params) do return connection.get(url, params) end end |
#in_parallel ⇒ Object
Does a parallel request to the api for all of the requests in the block
92 93 94 95 96 |
# File 'lib/yotpo/client.rb', line 92 def in_parallel connection.in_parallel do yield end end |
#post(url, params) ⇒ Object
Does a POST request to the url with the params
55 56 57 58 59 60 |
# File 'lib/yotpo/client.rb', line 55 def post(url, params) params = convert_hash_keys(params) preform(url, :post, params: params) do return connection.post(url, params) end end |
#put(url, params) ⇒ Object
Does a PUT request to the url with the params
67 68 69 70 71 72 |
# File 'lib/yotpo/client.rb', line 67 def put(url, params) params = convert_hash_keys(params) preform(url, :put, params: params) do return connection.put(url, params) end end |