lucid_shopify-resource 0.5.3 → 0.6.0
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 +4 -4
- data/lib/lucid_shopify/resource/base.rb +8 -3
- data/lib/lucid_shopify/resource/create.rb +11 -1
- data/lib/lucid_shopify/resource/delete.rb +9 -1
- data/lib/lucid_shopify/resource/read.rb +3 -3
- data/lib/lucid_shopify/resource/update.rb +8 -1
- data/lib/lucid_shopify/resource/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 128de0ab9db042cb27d00bdcf1210a2c605726afc7ab167b1b0273141ab15d6b
|
4
|
+
data.tar.gz: 1dfcbc9cce9734e915451abc21313baa9c17c52d7923d70e26f39724124e8595
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cd71fcea5deabd39aa71d324d026038e6a0e3c75d5761e7db8e3836a0c989e85a28a2e0b98a394e20815e8f3d83ec5a313ad4ba12ed38472d23f09f7df26d6d
|
7
|
+
data.tar.gz: 0e3595492bcbeac153ce84fa31790886cbf7b7cddd9af7a56dcf502f5fdf447516a2fc9eaa42a97eb7e672a25aa8dceeea50caea24c7457693a1d8b6708c1d57
|
@@ -9,15 +9,20 @@ module LucidShopify
|
|
9
9
|
module Base
|
10
10
|
module ClassMethods
|
11
11
|
#
|
12
|
-
# Set the remote API resource name for the subclass.
|
12
|
+
# Set the remote API resource name for the subclass. If a singular
|
13
|
+
# is not provided, the plural will be used, without any trailing 's'.
|
13
14
|
#
|
14
|
-
# @param
|
15
|
+
# @param resource_plural [String, #to_s]
|
16
|
+
# @param resource_singular [String, #to_s, nil]
|
15
17
|
#
|
16
18
|
# @example
|
17
19
|
# resource :orders
|
18
20
|
#
|
19
|
-
def resource(
|
21
|
+
def resource(resource_plural, resource_singular = nil)
|
20
22
|
define_method(:resource) { resource_name.to_s }
|
23
|
+
define_method(:resource_singular) do
|
24
|
+
resource_singular.nil? ? resource_plural.to_s.sub(/s$/, '') : resource_singular.to_s
|
25
|
+
end
|
21
26
|
end
|
22
27
|
end
|
23
28
|
|
@@ -17,8 +17,18 @@ module LucidShopify
|
|
17
17
|
module Create
|
18
18
|
def self.included(base)
|
19
19
|
base.include(Base)
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# @param credentials [Credentials]
|
24
|
+
# @param data [Hash]
|
25
|
+
#
|
26
|
+
# @return [Integer] the new ID
|
27
|
+
#
|
28
|
+
def create(credentials, data)
|
29
|
+
response = client.post_json(credentials, resource, resource_singular => data)
|
20
30
|
|
21
|
-
|
31
|
+
response.data_hash.dig(resource_singular, 'id')
|
22
32
|
end
|
23
33
|
end
|
24
34
|
end
|
@@ -17,8 +17,16 @@ module LucidShopify
|
|
17
17
|
module Delete
|
18
18
|
def self.included(base)
|
19
19
|
base.include(Base)
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# @param credentials [Credentials]
|
24
|
+
# @param id [Integer]
|
25
|
+
#
|
26
|
+
def delete(credentials, id)
|
27
|
+
logger.info("Deleting #{resource_singular} id=#{id}")
|
20
28
|
|
21
|
-
|
29
|
+
client.delete(credentials, "#{resource}/#{id}")
|
22
30
|
end
|
23
31
|
end
|
24
32
|
end
|
@@ -60,7 +60,7 @@ module LucidShopify
|
|
60
60
|
end
|
61
61
|
|
62
62
|
#
|
63
|
-
# @param credentials [
|
63
|
+
# @param credentials [Credentials]
|
64
64
|
# @param id [Integer]
|
65
65
|
# @param params [Hash]
|
66
66
|
#
|
@@ -81,7 +81,7 @@ module LucidShopify
|
|
81
81
|
#
|
82
82
|
# Throttling is always enabled.
|
83
83
|
#
|
84
|
-
# @param credentials [
|
84
|
+
# @param credentials [Credentials]
|
85
85
|
# @param params [Hash]
|
86
86
|
#
|
87
87
|
# @yield [Hash]
|
@@ -124,7 +124,7 @@ module LucidShopify
|
|
124
124
|
end
|
125
125
|
|
126
126
|
#
|
127
|
-
# @param credentials [
|
127
|
+
# @param credentials [Credentials]
|
128
128
|
# @param params [Hash]
|
129
129
|
#
|
130
130
|
# @return [Integer]
|
@@ -17,8 +17,15 @@ module LucidShopify
|
|
17
17
|
module Update
|
18
18
|
def self.included(base)
|
19
19
|
base.include(Base)
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
+
#
|
23
|
+
# @param credentials [Credentials]
|
24
|
+
# @param id [Integer]
|
25
|
+
# @param data [Hash]
|
26
|
+
#
|
27
|
+
def update(credentials, id, data)
|
28
|
+
client.put_json(credentials, "#{resource}/#{id}", resource_singular => data)
|
22
29
|
end
|
23
30
|
end
|
24
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lucid_shopify-resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelsey Judson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0.
|
47
|
+
version: '0.26'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0.
|
54
|
+
version: '0.26'
|
55
55
|
description:
|
56
56
|
email: kelsey@lucid.nz
|
57
57
|
executables: []
|