buezli-api 0.1.0 → 0.1.1
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/README.md +4 -1
- data/lib/buezli/api/client/record.rb +6 -5
- data/lib/buezli/api/client.rb +1 -1
- data/lib/buezli/api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 46c3eaef0c534db886a6f3536098616b004bc520629a00398651e3d9f4ae2427
|
|
4
|
+
data.tar.gz: 78cc040c2aaad5dc8e98b7795b056d2716293d1869eb08dcc2df085c4d35e82b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4bb3820291636601435a7424404f455e2da6d20864920c4a030d1476cf70c670c0be6c66ac7e5b8d95c9bc448231f5a8a42ffded32312dd44346cd56ec24eb47
|
|
7
|
+
data.tar.gz: a9500ba6c2bffe3c20afcf3063f88d9493699226958b66c1f00aa46dfd08a702149a03a1e856b7003d46f6d33c8be4088b1c3ae911a897f78f439bd79b07b322
|
data/README.md
CHANGED
|
@@ -49,7 +49,10 @@ client = Buezli::Api::Client.new(
|
|
|
49
49
|
Schema-declared dates and timestamps become `Date` and `Time`. Decimal values
|
|
50
50
|
remain strings and money remains a `cents`/`currency` hash, avoiding precision
|
|
51
51
|
loss. Unknown record methods raise `NoMethodError`; declared but absent fields
|
|
52
|
-
return `nil`.
|
|
52
|
+
return `nil`. Schema fields take precedence over client implementation details,
|
|
53
|
+
so an expanded `client` association is available as `record.client`. The
|
|
54
|
+
transport client used to build nested records is available separately as
|
|
55
|
+
`record.api_client`.
|
|
53
56
|
|
|
54
57
|
## Pagination and deltas
|
|
55
58
|
|
|
@@ -2,13 +2,14 @@ module Buezli
|
|
|
2
2
|
module Api
|
|
3
3
|
class Client
|
|
4
4
|
class Record
|
|
5
|
-
attr_reader :raw_attributes, :model_name, :
|
|
5
|
+
attr_reader :raw_attributes, :model_name, :api_client, :schema
|
|
6
6
|
|
|
7
|
-
def initialize(attributes:, model_name:,
|
|
7
|
+
def initialize(attributes:, model_name:, schema:, api_client: nil, client: nil)
|
|
8
8
|
@raw_attributes = (attributes || {}).with_indifferent_access
|
|
9
9
|
@model_name = model_name
|
|
10
|
-
@
|
|
10
|
+
@api_client = api_client || client
|
|
11
11
|
@schema = schema
|
|
12
|
+
raise ArgumentError, "api_client is required" unless @api_client
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def id
|
|
@@ -55,9 +56,9 @@ module Buezli
|
|
|
55
56
|
|
|
56
57
|
target_model = schema.association_class_name(model_name, name)
|
|
57
58
|
if schema.association_collection?(model_name, name)
|
|
58
|
-
Array(value).map { |attributes|
|
|
59
|
+
Array(value).map { |attributes| api_client.build_record(target_model, attributes) }
|
|
59
60
|
else
|
|
60
|
-
|
|
61
|
+
api_client.build_record(target_model, value)
|
|
61
62
|
end
|
|
62
63
|
end
|
|
63
64
|
|
data/lib/buezli/api/client.rb
CHANGED
data/lib/buezli/api/version.rb
CHANGED