vindi-rails 0.2.0 → 0.3.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.
@@ -1,14 +1,18 @@
1
- # frozen_string_literal: true
2
-
3
- module Vindi
4
- module APIOperations
5
- module Create
6
- def create(params = {})
7
- response = Client.request(:post, endpoint, params)
8
- singular_key = endpoint.end_with?("batches") ? endpoint.sub(/es$/, "").to_sym : endpoint.chomp("s").to_sym
9
- resource_attrs = response.key?(singular_key) ? response[singular_key] : response
10
- new(resource_attrs)
11
- end
12
- end
13
- end
14
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Vindi
4
+ module APIOperations
5
+ module Create
6
+ def create(params = {}, opts = {})
7
+ headers = {}
8
+ headers["Idempotency-Key"] = opts[:idempotency_key] if opts[:idempotency_key]
9
+ headers.merge!(opts[:headers]) if opts[:headers]
10
+
11
+ response = Client.request(:post, endpoint, params, headers)
12
+ singular_key = endpoint.end_with?("batches") ? endpoint.sub(/es$/, "").to_sym : endpoint.chomp("s").to_sym
13
+ resource_attrs = response.key?(singular_key) ? response[singular_key] : response
14
+ new(resource_attrs)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,14 +1,18 @@
1
- # frozen_string_literal: true
2
-
3
- module Vindi
4
- module APIOperations
5
- module Update
6
- def update(id, params = {})
7
- response = Client.request(:put, "#{endpoint}/#{id}", params)
8
- singular_key = endpoint.end_with?("batches") ? endpoint.sub(/es$/, "").to_sym : endpoint.chomp("s").to_sym
9
- resource_attrs = response.key?(singular_key) ? response[singular_key] : response
10
- new(resource_attrs)
11
- end
12
- end
13
- end
14
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Vindi
4
+ module APIOperations
5
+ module Update
6
+ def update(id, params = {}, opts = {})
7
+ headers = {}
8
+ headers["Idempotency-Key"] = opts[:idempotency_key] if opts[:idempotency_key]
9
+ headers.merge!(opts[:headers]) if opts[:headers]
10
+
11
+ response = Client.request(:put, "#{endpoint}/#{id}", params, headers)
12
+ singular_key = endpoint.end_with?("batches") ? endpoint.sub(/es$/, "").to_sym : endpoint.chomp("s").to_sym
13
+ resource_attrs = response.key?(singular_key) ? response[singular_key] : response
14
+ new(resource_attrs)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,31 +1,36 @@
1
- # frozen_string_literal: true
2
-
3
- module Vindi
4
- class Resource
5
- attr_reader :attributes
6
-
7
- def initialize(attributes = {})
8
- @attributes = attributes || {}
9
- end
10
-
11
- def inspect
12
- "#<#{self.class} #{attributes.inspect}>"
13
- end
14
-
15
- def method_missing(method_name, *args, &block)
16
- if attributes.key?(method_name)
17
- attributes[method_name]
18
- else
19
- super
20
- end
21
- end
22
-
23
- def respond_to_missing?(method_name, include_private = false)
24
- attributes.key?(method_name) || super
25
- end
26
-
27
- def self.endpoint
28
- raise NotImplementedError, "Subclasses must implement .endpoint"
29
- end
30
- end
31
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Vindi
4
+ class Resource
5
+ attr_reader :attributes
6
+
7
+ def initialize(attributes = {})
8
+ @attributes = attributes || {}
9
+ end
10
+
11
+ def inspect
12
+ "#<#{self.class} #{attributes.inspect}>"
13
+ end
14
+
15
+ def method_missing(method_name, *args, &block)
16
+ if attributes.key?(method_name)
17
+ attributes[method_name]
18
+ else
19
+ super
20
+ end
21
+ end
22
+
23
+ def respond_to_missing?(method_name, include_private = false)
24
+ attributes.key?(method_name) || super
25
+ end
26
+
27
+ def self.endpoint
28
+ raise NotImplementedError, "Subclasses must implement .endpoint"
29
+ end
30
+
31
+ def self.find(id)
32
+ response = Client.request(:get, "#{endpoint}/#{id}")
33
+ new(response)
34
+ end
35
+ end
36
+ end
data/lib/vindi/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vindi
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vindi-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wesley Lima
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-06-10 00:00:00.000000000 Z
11
+ date: 2026-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client