yotpo 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +47 -0
- data/changelog +1 -0
- data/lib/yotpo/api/purchase.rb +1 -0
- data/lib/yotpo/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -91,6 +91,53 @@ response.body.bottomline.average_score
|
|
91
91
|
|
92
92
|
Now lets try something a little bit more complicated. Lets try to create a purchase.
|
93
93
|
|
94
|
+
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.
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
ak = "d3n27Sg0eP8MHmVCHfPdQzyxjhwIEeV5cBKhoggC" #remember to replace the APP_KEY with your own.
|
98
|
+
st = "adsfasdf68ads6fadsfkjbhkljhciolqewrnqwew" #remember to replace the SECRET with your own.
|
99
|
+
|
100
|
+
|
101
|
+
# retrieving the utoken - will be valid for 24 hours
|
102
|
+
response = Yotpo.get_oauth_token :app_key => ak, :secret => st
|
103
|
+
utoken = response.body.access_token
|
104
|
+
|
105
|
+
#first creating the products that are in the order, notice that the key of the product hash is the product_sku
|
106
|
+
products = {
|
107
|
+
"BLABLA1" => {
|
108
|
+
:url => "http://shop.yotpo.com/products/amazing-yotpo-poster",
|
109
|
+
:name => "Yotpo Amazing Poster",
|
110
|
+
:image_url => "http://cdn.shopify.com/s/files/1/0098/1912/products/qa2_medium.png?41",
|
111
|
+
:description => "this is the most awesome poster in the world!",
|
112
|
+
:price => "100"
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
# now we will create a purchase using this the token we have received in the previous step
|
117
|
+
|
118
|
+
response = Yotpo.create_new_purchase :app_key => ak,
|
119
|
+
:utoken => utoken,
|
120
|
+
:email => "trial@yotpo.com",
|
121
|
+
:customer_name => "bob",
|
122
|
+
:order_id => "12999",
|
123
|
+
:platform => "Shopify",
|
124
|
+
:order_date => "2013-05-28",
|
125
|
+
:products => products,
|
126
|
+
:currency_iso => "USD"
|
127
|
+
|
128
|
+
#making sure our request went through
|
129
|
+
|
130
|
+
raise Exception unless response.body.code == 200
|
131
|
+
|
132
|
+
```
|
133
|
+
|
134
|
+
We can pull all the purchases of a certain account to make sure that the previous calls has worked
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
|
138
|
+
response = Yotpo.get_purchases :app_key => ak, :utoken => utoken, :since_date => "2013-05-26"
|
139
|
+
|
140
|
+
```
|
94
141
|
|
95
142
|
|
96
143
|
[register]: https://www.yotpo.com/register
|
data/changelog
CHANGED
data/lib/yotpo/api/purchase.rb
CHANGED
data/lib/yotpo/version.rb
CHANGED