quintype-api 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ba7e30c793fff129ef3b6fd8d8dbeff37d675ee
4
- data.tar.gz: 8861dd6bc1624eec82d3a258c534fe16f96c13dd
3
+ metadata.gz: 10c1012bf469aef0d78783d302b9b970804e5cd8
4
+ data.tar.gz: 8dfaeefdc8b52436457fbb069bce38ccd88844bd
5
5
  SHA512:
6
- metadata.gz: 20a9ed8f6d909d93f1a3cd88a35366798ef30405a372e9b3436986a20337932b08a435abe30074c73c40085d3791390e7fd57fca40b3a0aefceea4c8a80db312
7
- data.tar.gz: 1b0295a1b6df43cde1f99daa180ada0a33e28688b5201c4cb26ceb16a9ceae0294ce0d7f44fa3a5aecf56a8428a2af5005af1cb3fef3d7af5a0d967d376e5ac3
6
+ metadata.gz: 1d682835eec47a0e0176f1a4a0f5fd314dad7873c300848139a0b6191f534e8c97d26ab3f63a08f705c4ccb465fdd0a4aea80b17d5354be1d89ccf1d4ccf7edb
7
+ data.tar.gz: 43134e059e881c2b5f3fb720d1600d60e58efac34b2f483761b095a8ecdb98e21c0ba7b5f4c4272dcd4fecdaf450076bd92c9efe4c3662e1ba4fc2e367e2e2ae
data/README.md CHANGED
@@ -32,13 +32,25 @@ Quintype::API::Client.establish_connection("http://sketches.quintype.com", Farad
32
32
 
33
33
  ### Subclassing API classes
34
34
 
35
- It is highly recommended that you subclass API sections. This is mostly honored during requests
35
+ It is highly recommended that you subclass API sections. This is mostly honored during requests. If you use liquid, implement a to_liquid method.
36
36
 
37
37
  ```ruby
38
38
  class QtConfig < Quintype::API::Config
39
+ def to_liquid
40
+ ActiveSupport::HashWithIndifferentAccess.new to_h
41
+ end
39
42
  end
40
43
 
41
44
  class Story < Quintype::API::Story
45
+ def to_liquid
46
+ ActiveSupport::HashWithIndifferentAccess.new to_h
47
+ end
48
+ end
49
+
50
+ class Author < Quintype::API::Author
51
+ def to_liquid
52
+ ActiveSupport::HashWithIndifferentAccess.new to_h
53
+ end
42
54
  end
43
55
  ```
44
56
 
@@ -0,0 +1,9 @@
1
+ module Quintype::API
2
+ class Author < Base(%w(id name slug email avatar-url avatar-s3-key twitter-handle))
3
+ class << self
4
+ def find(id)
5
+ from_hash Client.instance.get_author(id).to_h
6
+ end
7
+ end
8
+ end
9
+ end
@@ -24,5 +24,9 @@ module Quintype::API
24
24
  def get_response(name)
25
25
  @responses[name]
26
26
  end
27
+
28
+ def cache_keys(opts = {})
29
+ @responses.values.flat_map { |response| response.respond_to?(:cache_keys) ? response.cache_keys(opts) : [] }
30
+ end
27
31
  end
28
32
  end
@@ -60,6 +60,12 @@ module Quintype::API
60
60
  response.body["results"]
61
61
  end
62
62
 
63
+ def get_author(author_id)
64
+ response = get("/api/v1/authors/#{author_id}")
65
+ raise ClientException.new("Could not get authors", response) unless response.status == 200
66
+ response.body["author"]
67
+ end
68
+
63
69
  def post_bulk(requests)
64
70
  response = post("/api/v1/bulk", requests: requests)
65
71
  raise ClientException.new("Could not bulk fetch", response) unless response.status == 200
@@ -1,5 +1,5 @@
1
1
  module Quintype
2
2
  module Api
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
data/lib/quintype/api.rb CHANGED
@@ -20,6 +20,7 @@ module Quintype
20
20
  autoload :Stack, "quintype/api/stack"
21
21
  autoload :Story, "quintype/api/story"
22
22
  autoload :Tag, "quintype/api/tag"
23
+ autoload :Author, "quintype/api/author"
23
24
 
24
25
  autoload :StackCollection, "quintype/api/stack_collection"
25
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quintype-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tejas Dinkar
@@ -81,6 +81,7 @@ files:
81
81
  - bin/console
82
82
  - bin/setup
83
83
  - lib/quintype/api.rb
84
+ - lib/quintype/api/author.rb
84
85
  - lib/quintype/api/base_functions.rb
85
86
  - lib/quintype/api/bulk.rb
86
87
  - lib/quintype/api/client.rb