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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff1195407764297a6ce5dae56293075abec7d5ab1dae4a4e0f3c12b4161c36d0
4
- data.tar.gz: 9499409ee428aa3c07d8afbf9c672cca1c35c78cde399a55d67d15ea937d133b
3
+ metadata.gz: 128de0ab9db042cb27d00bdcf1210a2c605726afc7ab167b1b0273141ab15d6b
4
+ data.tar.gz: 1dfcbc9cce9734e915451abc21313baa9c17c52d7923d70e26f39724124e8595
5
5
  SHA512:
6
- metadata.gz: cb8dc0742841ea2cf8c05930516b12e2659ec2f25cd376460b83fc5260a2bc1e7abda1462e72657f1879d4e14b1d2ac17f03f9441db5df7006fd82b8aed752e8
7
- data.tar.gz: a96f4013c232ef240fd3cea1e18fa542f54a383e1d77b01e9ebeec47fc61c4c29456c16ae43d276ad0af7df810e66563f66b9637d3e9159d16256bd3aeb214e7
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 resource_name [String, #to_s]
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(resource_name)
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
- raise NotImplementedError # TODO
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
- raise NotImplementedError # TODO
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 [RequestCredentials]
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 [RequestCredentials]
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 [RequestCredentials]
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
- raise NotImplementedError # TODO
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module LucidShopify
4
4
  module Resource
5
- VERSION = '0.5.3'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  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.5.3
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-07 00:00:00.000000000 Z
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.19'
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.19'
54
+ version: '0.26'
55
55
  description:
56
56
  email: kelsey@lucid.nz
57
57
  executables: []