the_one_api 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/README.md +22 -7
- data/lib/the_one_api/resources/base_resource.rb +19 -16
- data/lib/the_one_api/resources/quote.rb +1 -0
- data/lib/the_one_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: a1f9c32daa2104160e59593e3854d4e33cb0b6401f0e1600c97625a4166fcabe
|
4
|
+
data.tar.gz: 105c1e4ea840549ea4434e479d9d740331a845668a707e459e3936d749d6d5fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54d754600927c9a5b3a470c0f7b09f22d0e9df490317a20c9fa4bd35cc15387146e776b3f91e54d826a28ce7566de8584fcd09545eba110551373f9ef0eb11c1
|
7
|
+
data.tar.gz: f981d550128609b811e385ead09d58f2820369bb680d19cdaf82f42612d9cb9f7165b57f024f7ee2dece0cf76b9ddc206a72f6d70450c7a6bc97554ace02cd9f
|
data/README.md
CHANGED
@@ -58,6 +58,19 @@ movie.runtime_in_minutes
|
|
58
58
|
|
59
59
|
```
|
60
60
|
|
61
|
+
Query nested API resources (e.g. `/movie/{id}/quotes`) through method on the client named for the kind of entity you want to retrieve chained with a method using the `list_for_` naming convetion:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
require 'the_one_api'
|
65
|
+
|
66
|
+
client = TheOneApi::Client.new("your-API-key")
|
67
|
+
|
68
|
+
quotes = client.quote.list_for_movie("5cd95395de30eff6ebccde5b")
|
69
|
+
quotes.size
|
70
|
+
#=> 1000
|
71
|
+
```
|
72
|
+
|
73
|
+
|
61
74
|
### Errors
|
62
75
|
|
63
76
|
The client will raise `TheOneApi::HttpResponseError` when a request returns a bad status code:
|
@@ -78,18 +91,20 @@ end
|
|
78
91
|
|
79
92
|
## Supported API Features
|
80
93
|
|
81
|
-
### Currently Supported
|
94
|
+
### Currently Supported Endpoints/Operations
|
82
95
|
|
83
|
-
| Endpoint
|
84
|
-
|
|
85
|
-
| `/movie`
|
86
|
-
| `/
|
96
|
+
| Endpoint | SDK Entry Point | Operation |
|
97
|
+
| ------------------- | ---------------------------------------------- | --------------------------------------- |
|
98
|
+
| `/movie` | `TheOneApi::Client.movie.list` | list all movies |
|
99
|
+
| `/movie/{id}` | `TheOneApi::Client.movie.find({id})` | find a movie by id |
|
100
|
+
| `/movie/{id}/quote` | `TheOneApi::Client.quote.list_for_movie({id})` | list all quotes from a particular movie |
|
101
|
+
| `/quote` | `TheOneApi::Client.quote.list` | list all quotes |
|
102
|
+
| `/quote/{id}` | `TheOneApi::Client.quote.find({id}` | find a quote by id |
|
87
103
|
|
88
104
|
### Currently Unsupported Features
|
89
105
|
|
90
106
|
The SDK currently does not explicitly support
|
91
|
-
+
|
92
|
-
+ nested endpoints - e.g. `/movie/{id}/quote`
|
107
|
+
+ endpoints not listed above
|
93
108
|
+ Pagination, Sorting and Filtering as described [here](https://the-one-api.dev/documentation#5)
|
94
109
|
|
95
110
|
However, you can supply custom query parameters as a hash to any of the named resource methods on `TheOneApi::Client`, for example:
|
@@ -6,21 +6,24 @@ module TheOneApi
|
|
6
6
|
# Helper class to implement and wire in the response
|
7
7
|
# transformations needed by BaseResource (see below)
|
8
8
|
class BaseResourceProxy < Flexirest::ProxyBase
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
9
|
+
get(+".+") do
|
10
|
+
if @request.method[:method] == :get
|
11
|
+
# if this is a GET request to list multiple items
|
12
|
+
if @request.method[:name].match? "list"
|
13
|
+
response = passthrough
|
14
|
+
translate(response) do |body|
|
15
|
+
# give back the array of returned entities instead of the envelope
|
16
|
+
# structure that surrounds it
|
17
|
+
body["docs"] || body
|
18
|
+
end
|
19
|
+
# if this is a GET request to a single resource by id
|
20
|
+
elsif @request.method[:name].match? "find"
|
21
|
+
response = passthrough
|
22
|
+
translate(response) do |body|
|
23
|
+
# give back the entity instead of an array of one entity
|
24
|
+
body["docs"] && body["docs"][0] ? body["docs"][0] : body
|
25
|
+
end
|
26
|
+
end
|
24
27
|
end
|
25
28
|
end
|
26
29
|
end
|
@@ -28,7 +31,7 @@ module TheOneApi
|
|
28
31
|
# Common functionality for all API resources, including:
|
29
32
|
# + Adding authentication header
|
30
33
|
# + Unwrapping the `docs` array
|
31
|
-
# when listing
|
34
|
+
# when listing multiple items from a resource
|
32
35
|
# + Unwrapping the one item returned in the `docs` array
|
33
36
|
# when requesting a single entity by id
|
34
37
|
class BaseResource < Flexirest::Base
|
data/lib/the_one_api/version.rb
CHANGED