StemboltHQ/yotpo-ruby

Name: yotpo-ruby

Owner: Stembolt

Description: Ruby implementation of yotpo api connector

Created: 2015-09-17 20:44:49.0

Updated: 2015-09-17 20:44:51.0

Pushed: 2015-09-17 15:16:13.0

Homepage: null

Size: 128

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Yotpo

A Ruby interface to the YOTPO API

Gem Version Build Status Dependency Status Code Climate Coverage Status

Installation

Add this line to your application's Gemfile:

gem 'yotpo'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install yotpo
Usage

First register your application with Yotpo Then copy and past the app_key and secret

o.configure do |config|
nfig.app_key = APP_KEY
nfig.secret = SECRET

That is it you are ready

Now lets make some public calls to our api. Public calls only require you to use a valid app_key.

Creating your first review using the API

 "MY_APP_KEY"

o.create_review :app_key => ak, 
                :product_id => "BLABLA", 
                :shop_domain => "omri.co", 
                :product_title => "pt", 
                :product_description => "pd", 
                :product_url => "http://google.com/?q=myproducturl", 
                :product_image_url => "https://www.google.com/images/srpr/logo4w.png", 
                :user_display_name => "MOSHE", 
                :user_email => 'haim@yotpo.com', 
                :review_body => "this is my review body", 
                :review_title => "my review title" , 
                :review_score => 5

and now lets retrieve all the reviews of our product BLABLA

onse = Yotpo.get_product_reviews :app_key => ak, :product_id => "BLABLA"

eview = response.body.reviews.first

eview.title
 my review title

eview.score
 5

getting the bottom line of product BLABLA

onse = Yotpo.get_product_bottom_line :app_key => ak, :product_id => "BLABLA"

onse.body.bottomline.total_reviews
 1 

onse.body.bottomline.average_score
 5.0

Now lets try something a little bit more complicated. Lets try to create a purchase.

For that we will need to go through Yotpo authenticaton process, provide an app_key and secret, and return to get the utoken. The utoken will allow us to make authenticated API calls.

 "d3n27Sg0eP8MHmVCHfPdQzyxjhwIEeV5cBKhoggC" #remember to replace the APP_KEY with your own.
 "adsfasdf68ads6fadsfkjbhkljhciolqewrnqwew" #remember to replace the SECRET with your own.


trieving the utoken - will be valid for 24 hours
onse = Yotpo.get_oauth_token :app_key => ak, :secret => st
en = response.body.access_token

st creating the products that are in the order, notice that the key of the product hash is the product_sku
ucts = {
        "BLABLA1" => {
                :url => "http://shop.yotpo.com/products/amazing-yotpo-poster", 
                :name => "Yotpo Amazing Poster", 
                :image_url => "http://cdn.shopify.com/s/files/1/0098/1912/products/qa2_medium.png?41", 
                :description => "this is the most awesome poster in the world!", 
                :price => "100"
            }
        }

w we will create a purchase using this the token we have received in the previous step

onse = Yotpo.create_new_purchase    :app_key => ak, 
                                    :utoken => utoken, 
                                    :email => "trial@yotpo.com", 
                                    :customer_name => "bob", 
                                    :order_id => "12999", 
                                    :platform => "Shopify", 
                                    :order_date => "2013-05-28", 
                                    :products => products, 
                                    :currency_iso => "USD"

ing sure our request went through

e Exception unless response.body.code == 200 

We can pull all the purchases of a certain account to make sure that the previous calls has worked

onse = Yotpo.get_purchases :app_key => ak, :utoken => utoken, :since_date => "2013-05-26"
Contributing
  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.