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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/CHANGELOG.pt-BR.md +11 -0
- data/README.md +96 -74
- data/README.pt-BR.md +97 -74
- data/WIKI.md +479 -246
- data/WIKI.pt-BR.md +479 -246
- data/lib/vindi/api_operations/create.rb +18 -14
- data/lib/vindi/api_operations/update.rb +18 -14
- data/lib/vindi/resource.rb +36 -31
- data/lib/vindi/version.rb +1 -1
- metadata +2 -2
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Vindi
|
|
4
|
-
module APIOperations
|
|
5
|
-
module Create
|
|
6
|
-
def create(params = {})
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
data/lib/vindi/resource.rb
CHANGED
|
@@ -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
|
-
|
|
31
|
-
|
|
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
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.
|
|
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-
|
|
11
|
+
date: 2026-06-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rest-client
|