dooca_commerce 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dooca_commerce.rb +54 -2
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb05b281b4833e7e98c7f4c4557d72324132191638cd7bbc6abfc256e12b48ec
|
4
|
+
data.tar.gz: fb8e384411649ca865657a0cc9845901b44464ddf0ddea3ff477365e0beb738d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 809b7d6bc5f214db09999fa34834f0df8d5ee66c435e76666d1d4d6f2f2ecd8ad249ac9654355976c85ea0cdc348740edf01128b6b8d068ea45603f83ffadad2
|
7
|
+
data.tar.gz: 8c9cc86a2db205966e8fcc2441de4ed11d82ff30ce791e52c121384bbbf0d82fd923a419a8679c9a5f6fe8d9e6c0e8709b7ee681ac152119ad8164e76fed46d6
|
data/lib/dooca_commerce.rb
CHANGED
@@ -1,5 +1,57 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'response_handler'
|
3
|
+
|
1
4
|
class DoocaCommerce
|
2
|
-
|
3
|
-
|
5
|
+
|
6
|
+
def initialize(token:)
|
7
|
+
@token = token
|
8
|
+
@handler = ResponseHandler
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :token, :handler
|
12
|
+
|
13
|
+
def fetch_products(query = {})
|
14
|
+
response = connection.get("/products", query)
|
15
|
+
|
16
|
+
handler.new(response).parse!
|
17
|
+
end
|
18
|
+
|
19
|
+
def fetch_product(query = {})
|
20
|
+
response = connection.get("/products", query)
|
21
|
+
|
22
|
+
handler.new(response, single_from_list: true).parse!
|
23
|
+
end
|
24
|
+
|
25
|
+
def fetch_variations(query = {})
|
26
|
+
response = connection.get("/variations", query)
|
27
|
+
|
28
|
+
handler.new(response).parse!
|
29
|
+
end
|
30
|
+
|
31
|
+
def fetch_variation(query = {})
|
32
|
+
response = connection.get("/variations", query)
|
33
|
+
|
34
|
+
handler.new(response, single_from_list: true).parse!
|
35
|
+
end
|
36
|
+
|
37
|
+
def update_stock_and_price(product_id:, body:)
|
38
|
+
response = connection.put("/products/#{product_id}", body.to_json)
|
39
|
+
|
40
|
+
handler.new(response).parse!
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
URL = "https://api.dooca.store"
|
46
|
+
|
47
|
+
def headers
|
48
|
+
{
|
49
|
+
"Content-Type" => "application/json",
|
50
|
+
"Authorization": "Bearer #{token}"
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def connection
|
55
|
+
@connection ||= Faraday.new(url: URL, headers: headers)
|
4
56
|
end
|
5
57
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dooca_commerce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luciano Cesar Cordeiro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
12
|
-
dependencies:
|
11
|
+
date: 2021-12-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: A Ruby implementation of Dooca Commerce API
|
14
28
|
email: lucianocordeiro1991@hotmail.com
|
15
29
|
executables: []
|