cordial 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00e097395ce9076449736493f8ed557b941ac8ce
4
- data.tar.gz: c7cde2dd40046ae267bc7330dbb3ea9a7fb7b582
3
+ metadata.gz: 0dcf152bb33ca690ab905e561239fe97eda9c585
4
+ data.tar.gz: e2aabb3f2ba3808f9afc9ebcc18b7d21c9bacd01
5
5
  SHA512:
6
- metadata.gz: d28fd6abcbc527439679b89f71f5d3b4898c3d5e3aa73792e104c9c32acfeec62c2c5d2f8cf132437ec866f4a7458656f7d3d5b10310caa110513e4c1268837d
7
- data.tar.gz: fc6ba4dab4ba050346a558a5ca76308c7c682c3d60eaf413b9ecf565502ed799a47f845ee5aff34255d58ba41fe50682b4ba23fbec052590539b571baada2e54
6
+ metadata.gz: 2396e02c793ac977fea04f1613391311d7f55333814ddb4f0b6b3cece11a6a5e707c449ea5dda7dd74ad5ff27e900150b1adf1e6ca3fd816e0dd96e5266afc0f
7
+ data.tar.gz: 91ab6d0cbcf3d0a600f997e9a5acdaa46aaf409f45c28c5c0df5dfa4869f0e417d90f20f368fa307c83b4f2609367b2b348f5d31ebbcba1469a5eef3fe5d7d94
@@ -0,0 +1,65 @@
1
+ module Cordial
2
+ # Wraps all interaction with the Order resource.
3
+ # @see https://api.cordial.io/docs/v1/#!/orders
4
+ class Orders
5
+ include ::HTTParty
6
+ extend Client
7
+
8
+ # Find an order
9
+ # @example Usage
10
+ # Cordial::Orders.find(id: 1)
11
+ # @example Response when the order was found
12
+ # {
13
+ # "_id"=>"5b3a774a2cab4e1a59d0cc6d",
14
+ # "orderID"=>"1",
15
+ # "purchaseDate"=>"2015-01-10T01:47:43+0000",
16
+ # "items"=>[
17
+ # {
18
+ # "productID"=>"1",
19
+ # "sku"=>"123",
20
+ # "name"=>"Test product",
21
+ # "attr"=>{
22
+ # "color"=>"blue",
23
+ # "size"=>"L"
24
+ # },
25
+ # "amount"=>0
26
+ # }
27
+ # ],
28
+ # "cID"=>"5aea409bbb3dc2f9bc27158f",
29
+ # "totalAmount"=>0
30
+ # }
31
+ #
32
+ # @example Response when the order was not found.
33
+ # {"error"=>true, "message"=>"record not found"}
34
+ def self.find(id:)
35
+ client.get("/orders/#{id}")
36
+ end
37
+
38
+ # Create a new order.
39
+ # Posting more than one time the same "orderID" name will generate an error.
40
+ #
41
+ # @example Usage.
42
+ # Cordial::Orders.create(
43
+ # id: 1,
44
+ # email: 'cordial@example.com',
45
+ # purchase_date: '2015-01-09 17:47:43',
46
+ # items: [{productID: '1',
47
+ # sku: '123',
48
+ # name: 'Test product',
49
+ # attr: { color: 'blue', size: 'L' }}])
50
+ # @example response whe the orderID is not on cordial
51
+ # {"success"=>true}
52
+ #
53
+ # @example Response when orderID already exist on cordial.
54
+ # {"error"=>true, "messages"=>"ID must be unique"}
55
+ def self.create(id:, email:, purchase_date:, items:)
56
+ client.post('/orders',
57
+ body: {
58
+ orderID: id,
59
+ email: email,
60
+ purchaseDate: purchase_date,
61
+ items: items
62
+ }.to_json)
63
+ end
64
+ end
65
+ end
@@ -7,7 +7,7 @@ module Cordial
7
7
 
8
8
  # Find a product.
9
9
  # @example Usage
10
- # Cordial::products.find(product_id: 1)
10
+ # Cordial::Products.find(id: 1)
11
11
  # @example Response when the product was found.
12
12
  # {
13
13
  # "_id"=>"5b28275fe1dc0fa0c872abec",
@@ -37,8 +37,8 @@ module Cordial
37
37
  # If the product already exists it will be updated.
38
38
  # @example Usage.
39
39
  # Cordial::Products.create(
40
- # product_id: 1,
41
- # product_name: 'Test Product',
40
+ # id: 1,
41
+ # name: 'Test Product',
42
42
  # price: 99.99,
43
43
  # variants: [{
44
44
  # sku: '123',
@@ -1,3 +1,3 @@
1
1
  module Cordial
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
data/lib/cordial.rb CHANGED
@@ -4,6 +4,7 @@ require "cordial/version"
4
4
  require "cordial/client"
5
5
  require "cordial/contacts"
6
6
  require "cordial/products"
7
+ require "cordial/orders"
7
8
 
8
9
  module Cordial
9
10
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cordial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Hood
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-25 00:00:00.000000000 Z
11
+ date: 2018-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -130,6 +130,7 @@ files:
130
130
  - lib/cordial.rb
131
131
  - lib/cordial/client.rb
132
132
  - lib/cordial/contacts.rb
133
+ - lib/cordial/orders.rb
133
134
  - lib/cordial/products.rb
134
135
  - lib/cordial/version.rb
135
136
  - lib/utils/compact.rb