Class: Yotpo::Client
- Inherits:
-
Object
- Object
- Yotpo::Client
- Includes:
- Account, AccountPlatform, AccountSocial, Answer, Comment, Feature, Image, Oauth, OwnerFeature, OwnerFeatureSetting, Product, Purchase, Question, Reminder, Review, User
- Defined in:
- lib/yotpo/client.rb
Instance Method Summary collapse
-
#delete(url, params) ⇒ 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 Answer
Methods included from Question
#question_create_by_token, #question_send_confirmation
Methods included from User
#anonymous_user_confirmation, #create_user, #get_login_url, #get_oauth_token
Methods included from Review
#add_vote_to_review, #create_review, #get_all_reviews, #get_product_reviews, #get_review
Methods included from Reminder
Methods included from Product
#get_all_bottom_lines, #get_product_bottom_line, #get_product_url, #get_products_information
Methods included from OwnerFeatureSetting
#get_feature_settings, #mass_update_feature_settings, #owner_feature_settings, #update_feature_settings
Methods included from OwnerFeature
#add_feature, #get_owner_features, #remove_feature, #user_enable_feature
Methods included from Oauth
Methods included from Image
Methods included from Feature
Methods included from Comment
#create_comment, #update_comment, #update_comment_avatar
Methods included from AccountSocial
#create_account_social, #get_account_social, #update_account_social
Methods included from AccountPlatform
Methods included from Account
#check_lock_state, #check_minisite_subdomain, #update_account
Constructor Details
#initialize(url = 'https://api.yotpo.com', parallel_requests = 5) ⇒ Client
Creates a new instance of Yotpo::Client
50 51 52 53 |
# File 'lib/yotpo/client.rb', line 50 def initialize(url = 'https://api.yotpo.com', parallel_requests = 5) @url = url @parallel_requests = parallel_requests end |
Instance Method Details
#delete(url, params) ⇒ Object
Does a DELETE request to the url with the params
95 96 97 98 99 100 |
# File 'lib/yotpo/client.rb', line 95 def delete(url, params) params = convert_hash_keys(params) preform(url, :delete, params: params) do return connection.delete(url, params) end end |
#get(url, params = {}) ⇒ Object
Does a GET request to the url with the params
60 61 62 63 64 65 |
# File 'lib/yotpo/client.rb', line 60 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
110 111 112 113 114 |
# File 'lib/yotpo/client.rb', line 110 def in_parallel connection.in_parallel do yield end end |
#post(url, params) ⇒ Object
Does a POST request to the url with the params
72 73 74 75 76 77 |
# File 'lib/yotpo/client.rb', line 72 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
84 85 86 87 88 89 |
# File 'lib/yotpo/client.rb', line 84 def put(url, params) params = convert_hash_keys(params) preform(url, :put, params: params) do return connection.put(url, params) end end |