tito_ruby 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 +8 -1
- data/README.md +27 -0
- data/lib/tito/admin/query_builder.rb +1 -1
- data/lib/tito/configuration.rb +1 -1
- data/lib/tito/connection.rb +1 -0
- data/lib/tito/railtie.rb +7 -0
- data/lib/tito/version.rb +1 -1
- data/lib/tito.rb +10 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d5aff44c4d4d1c7ba8d35c33db508172e27763bcc264498c320b7924fd04c2e5
|
|
4
|
+
data.tar.gz: 9c7b0dd2172f7fd5d1e42ac48169f0c273421ba2ff7e798e37195cc54301ff98
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 22b86e2c5069e40e5062f456f42fd702a30dba9cf6fda7df5b4e4b832c14195ba3d002bcbaedb6c9effabf3e3978f11a39a7db6ebbbc7b534dc468b80adfa91d
|
|
7
|
+
data.tar.gz: 79332e529d1f7f557f433146e0bf3883be3603c47d5370c9295c4b6bd1e6b4c00e4dbd7dd9ce675849dbdca3340940d28376392a666ab330eb1b2b8bf91d2733
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.3.0 (Unreleased)
|
|
4
|
+
|
|
5
|
+
- Added request logging via Faraday's built-in logger middleware
|
|
6
|
+
- Added `Tito.logger` / `Tito.logger=` for easy logger configuration
|
|
7
|
+
- Added Rails Railtie that auto-sets `Tito.logger = Rails.logger`
|
|
8
|
+
- Fixed QueryBuilder array params adding an extra `[]` suffix (e.g. `where(state: ["complete"])` now sends correctly)
|
|
9
|
+
|
|
10
|
+
## 0.2.0
|
|
4
11
|
|
|
5
12
|
- Updated all resource definitions to match actual Tito API v3 responses
|
|
6
13
|
- Fixed Resource to silently drop unknown attributes from API responses instead of crashing
|
data/README.md
CHANGED
|
@@ -122,6 +122,33 @@ client.tickets
|
|
|
122
122
|
|
|
123
123
|
:white_check_mark: = tested against live API  :grey_question: = implemented but untested  :x: = known broken
|
|
124
124
|
|
|
125
|
+
## Logging
|
|
126
|
+
|
|
127
|
+
In a Rails app, request logging is enabled automatically via `Rails.logger`. You'll see output like:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
request: GET https://api.tito.io/v3/letterblock/test-event-1/tickets?page%5Bnumber%5D=1
|
|
131
|
+
response: Status 200
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Outside of Rails, set a logger manually:
|
|
135
|
+
|
|
136
|
+
```ruby
|
|
137
|
+
Tito.logger = Logger.new(STDOUT)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Or via the configure block:
|
|
141
|
+
|
|
142
|
+
```ruby
|
|
143
|
+
Tito.configure do |config|
|
|
144
|
+
config.logger = Logger.new(STDOUT)
|
|
145
|
+
end
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
This uses Faraday's built-in logger middleware, omitting headers and bodies. Set `Tito.logger = nil` to disable.
|
|
149
|
+
|
|
150
|
+
Note: the logger is captured when the first request is made on a client. If you set `Tito.logger` after a client has already been used, create a new client for it to take effect.
|
|
151
|
+
|
|
125
152
|
## Development
|
|
126
153
|
|
|
127
154
|
```
|
|
@@ -73,7 +73,7 @@ module Tito
|
|
|
73
73
|
when Array
|
|
74
74
|
plural_key = key.to_s
|
|
75
75
|
plural_key = plural_key.end_with?("s") ? plural_key : "#{plural_key}s"
|
|
76
|
-
params["search[#{plural_key}]
|
|
76
|
+
params["search[#{plural_key}]"] = value.map(&:to_s)
|
|
77
77
|
when Range
|
|
78
78
|
if value.begin
|
|
79
79
|
params["search[#{key}][gte]"] = format_value(value.begin)
|
data/lib/tito/configuration.rb
CHANGED
data/lib/tito/connection.rb
CHANGED
|
@@ -28,6 +28,7 @@ module Tito
|
|
|
28
28
|
f.headers["Authorization"] = "Token token=#{@token}"
|
|
29
29
|
f.headers["Accept"] = "application/json"
|
|
30
30
|
f.request :json
|
|
31
|
+
f.response :logger, Tito.logger, headers: false, bodies: false if Tito.logger
|
|
31
32
|
f.response :json, content_type: /\bjson$/
|
|
32
33
|
end
|
|
33
34
|
end
|
data/lib/tito/railtie.rb
ADDED
data/lib/tito/version.rb
CHANGED
data/lib/tito.rb
CHANGED
|
@@ -51,12 +51,22 @@ module Tito
|
|
|
51
51
|
@configuration ||= Configuration.new
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
+
def logger
|
|
55
|
+
configuration.logger
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def logger=(logger)
|
|
59
|
+
configuration.logger = logger
|
|
60
|
+
end
|
|
61
|
+
|
|
54
62
|
def reset_configuration!
|
|
55
63
|
@configuration = Configuration.new
|
|
56
64
|
end
|
|
57
65
|
end
|
|
58
66
|
end
|
|
59
67
|
|
|
68
|
+
require "tito/railtie" if defined?(Rails::Railtie)
|
|
69
|
+
|
|
60
70
|
# Register custom types
|
|
61
71
|
ActiveModel::Type.register(:string_array, Tito::Types::StringArray)
|
|
62
72
|
ActiveModel::Type.register(:integer_array, Tito::Types::IntegerArray)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tito_ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joshua Paine
|
|
@@ -147,6 +147,7 @@ files:
|
|
|
147
147
|
- lib/tito/configuration.rb
|
|
148
148
|
- lib/tito/connection.rb
|
|
149
149
|
- lib/tito/errors.rb
|
|
150
|
+
- lib/tito/railtie.rb
|
|
150
151
|
- lib/tito/resource.rb
|
|
151
152
|
- lib/tito/types/integer_array.rb
|
|
152
153
|
- lib/tito/types/json.rb
|