Skip to content

Commit 4db2404

Browse files
Added ruby examples
1 parent 2f5dc94 commit 4db2404

File tree

9 files changed

+522
-0
lines changed

9 files changed

+522
-0
lines changed

source/includes/v2/_coupons.md

+53
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,33 @@ print_r($woocommerce->coupons->create($data));
155155
?>
156156
```
157157

158+
```ruby
159+
data = {
160+
coupon: {
161+
code: "new-coupon",
162+
type: "percent",
163+
amount: "10",
164+
individual_use: true,
165+
product_ids: [],
166+
exclude_product_ids: [],
167+
usage_limit: "",
168+
usage_limit_per_user: "",
169+
limit_usage_to_x_items: "",
170+
expiry_date: "",
171+
enable_free_shipping: false,
172+
product_category_ids: [],
173+
exclude_product_category_ids: [],
174+
exclude_sale_items: true,
175+
minimum_amount: "100.00",
176+
maximum_amount: "0.00",
177+
customer_emails: [],
178+
description: ""
179+
}
180+
}
181+
182+
woocommerce.post("coupons", data).parsed_response
183+
```
184+
158185
> JSON response example:
159186
160187
```json
@@ -225,6 +252,10 @@ print(wcapi.get("coupons/529").json())
225252
<?php print_r($woocommerce->coupons->get(529)); ?>
226253
```
227254

255+
```ruby
256+
woocommerce.get("coupons/529").parsed_response
257+
```
258+
228259
> JSON response example:
229260
230261
```json
@@ -288,6 +319,10 @@ print(wcapi.get("coupons").json())
288319
<?php print_r($woocommerce->coupons->get()); ?>
289320
```
290321

322+
```ruby
323+
woocommerce.get("coupons").parsed_response
324+
```
325+
291326
> JSON response example:
292327
293328
```json
@@ -427,6 +462,16 @@ print_r($woocommerce->coupons->update(529, $data));
427462
?>
428463
```
429464

465+
```ruby
466+
data {
467+
coupon: {
468+
amount: "5"
469+
}
470+
}
471+
472+
woocommerce.put("coupons/529", data).parsed_response
473+
```
474+
430475
> JSON response example:
431476
432477
```json
@@ -490,6 +535,10 @@ print(wcapi.delete("coupons/529?force=true").json())
490535
<?php print_r($woocommerce->coupons->delete(529, true)); ?>
491536
```
492537

538+
```ruby
539+
woocommerce.delete("coupons/529?force=true").parsed_response
540+
```
541+
493542
> JSON response example:
494543
495544
```json
@@ -536,6 +585,10 @@ print(wcapi.get("coupons/count").json())
536585
<?php print_r($woocommerce->coupons->get_count()); ?>
537586
```
538587

588+
```ruby
589+
woocommerce.get("coupons/count").parsed_response
590+
```
591+
539592
> JSON response example:
540593
541594
```json

source/includes/v2/_customers.md

+77
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,43 @@ print_r($woocommerce->customers->create($data));
217217
?>
218218
```
219219

220+
```ruby
221+
data = {
222+
customer: {
223+
224+
first_name: "John",
225+
last_name: "Doe",
226+
username: "john.doe",
227+
billing_address: {
228+
first_name: "John",
229+
last_name: "Doe",
230+
company: "",
231+
address_1: "969 Market",
232+
address_2: "",
233+
city: "San Francisco",
234+
state: "CA",
235+
postcode: "94103",
236+
country: "US",
237+
238+
phone: "(555) 555-5555"
239+
},
240+
shipping_address: {
241+
first_name: "John",
242+
last_name: "Doe",
243+
company: "",
244+
address_1: "969 Market",
245+
address_2: "",
246+
city: "San Francisco",
247+
state: "CA",
248+
postcode: "94103",
249+
country: "US"
250+
}
251+
}
252+
}
253+
254+
woocommerce.post("customers", data).parsed_response
255+
```
256+
220257
> JSON response example:
221258
222259
```json
@@ -300,6 +337,10 @@ print(wcapi.get("customers/2").json())
300337
<?php print_r($woocommerce->customers->get(2)); ?>
301338
```
302339

340+
```ruby
341+
woocommerce.get("customers/2").parsed_response
342+
```
343+
303344
> JSON response example:
304345
305346
```json
@@ -376,6 +417,10 @@ print(wcapi.get("customers").json())
376417
<?php print_r($woocommerce->customers->get()); ?>
377418
```
378419

420+
```ruby
421+
woocommerce.get("customers").parsed_response
422+
```
423+
379424
> JSON response example:
380425
381426
```json
@@ -547,6 +592,22 @@ print_r($woocommerce->customers->update(2, $data));
547592
?>
548593
```
549594

595+
```ruby
596+
data = {
597+
customer: {
598+
first_name: "James",
599+
billing_address: {
600+
first_name: "James"
601+
},
602+
shipping_address: {
603+
first_name: "James"
604+
}
605+
}
606+
}
607+
608+
woocommerce.put("customers/2", data).parsed_response
609+
```
610+
550611
> JSON response example:
551612
552613
```json
@@ -623,6 +684,10 @@ print(wcapi.delete("customers/2").json())
623684
<?php print_r($woocommerce->customers->delete(2)); ?>
624685
```
625686

687+
```ruby
688+
woocommerce.delete("customers/2").parsed_response
689+
```
690+
626691
> JSON response example:
627692
628693
```json
@@ -663,6 +728,10 @@ print(wcapi.get("customers/2/orders").json())
663728
<?php print_r($woocommerce->customers->get_orders(2)); ?>
664729
```
665730

731+
```ruby
732+
woocommerce.get("customers/2/orders").parsed_response
733+
```
734+
666735
> JSON response example:
667736
668737
```json
@@ -824,6 +893,10 @@ print(wcapi.get("customers/2/downloads").json())
824893
<?php print_r($woocommerce->customers->get_downloads(2)); ?>
825894
```
826895

896+
```ruby
897+
woocommerce.get("customers/2/downloads").parsed_response
898+
```
899+
827900
> JSON response example:
828901
829902
```json
@@ -893,6 +966,10 @@ print(wcapi.get("customers/count").json())
893966
<?php print_r($woocommerce->customers->get_count()); ?>
894967
```
895968

969+
```ruby
970+
woocommerce.get("customers/count").parsed_response
971+
```
972+
896973
> JSON response example:
897974
898975
```json

source/includes/v2/_index.md

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ print(wcapi.get("").json())
7474
<?php print_r($woocommerce->index->get()); ?>
7575
```
7676

77+
```ruby
78+
woocommerce.get("").parsed_response
79+
```
80+
7781
> JSON response example:
7882
7983
```json

source/includes/v2/_introduction.md

+22
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ See the webhook resource section.
403403
- [Node.js](https://www.npmjs.com/package/woocommerce-api)
404404
- [Python](https://pypi.python.org/pypi/WooCommerce)
405405
- [PHP](https://packagist.org/packages/woothemes/woocommerce-api)
406+
- [Ruby](https://rubygems.org/gems/woocommerce_api)
406407

407408
```javascript
408409
// Install:
@@ -450,6 +451,27 @@ $woocommerce = new WC_API_Client(
450451
?>
451452
```
452453

454+
```ruby
455+
# Install:
456+
# gem install woocommerce_api
457+
458+
# Setup:
459+
require "woocommerce_api"
460+
461+
woocommerce = WooCommerce::API.new(
462+
"http://example.com",
463+
"consumer_key",
464+
"consumer_secret",
465+
{
466+
version: "v2"
467+
}
468+
)
469+
```
470+
471+
<aside class="notice">
472+
Use the tabs at the top-right corner to see how to install and use each library.
473+
</aside>
474+
453475
## Tools ##
454476

455477
* [CocoaRestClient](http://mmattozzi.github.io/cocoa-rest-client/) - A free, easy to use Mac OS X GUI client for interacting with the API, most useful when your test store has SSL enabled.

0 commit comments

Comments
 (0)