Class: API
- Inherits:
-
Object
show all
- Defined in:
- lib/quintype/api.rb,
lib/quintype/api/tag.rb,
lib/quintype/api/url.rb,
lib/quintype/api/stack.rb,
lib/quintype/api/story.rb,
lib/quintype/api/author.rb,
lib/quintype/api/story/reading_time.rb
Defined Under Namespace
Classes: Author, Stack, Story, Tag, URL
Class Method Summary
collapse
-
.author_profile(author_id) ⇒ Object
-
.authors(params) ⇒ Object
-
.bulk_post(params) ⇒ Object
-
.check_email(email) ⇒ Object
-
.comments_and_likes(story_ids) ⇒ Object
-
.config ⇒ Object
-
.conn ⇒ Object
-
.contact_publisher(params) ⇒ Object
-
.establish_connection(host, conn = Faraday.new(url: host)) ⇒ Object
-
.forgot_password(member) ⇒ Object
-
.get_member_metadata(session_cookie) ⇒ Object
-
.invite_users(emails, from_email, from_name) ⇒ Object
-
.login(provider, data) ⇒ Object
-
.login_member(auth) ⇒ Object
-
.logout ⇒ Object
-
.post_comment(story_content_id, text, parent_comment_id = nil, session_cookie) ⇒ Object
-
.related_stories(story_id, section, fields = []) ⇒ Object
-
.reset_password(params) ⇒ Object
-
.save_member_metadata(metadata, session_cookie) ⇒ Object
-
.search(options) ⇒ Object
-
.search_story_collection(name, options) ⇒ Object
-
.sections ⇒ Object
-
.signup_member(member) ⇒ Object
-
.stories(params, options = {}) ⇒ Object
-
.story(story_id) ⇒ Object
-
.story_by_slug(slug, params = {}) ⇒ Object
-
.story_collection(options) ⇒ Object
-
.story_collection_by_tag(options) ⇒ Object
-
.subscribe(member, profile, payment) ⇒ Object
-
.tag_by_name(tag_name) ⇒ Object
-
.unsubscribe(options) ⇒ Object
-
.unsubscribe_publisher(params) ⇒ Object
-
.videos ⇒ Object
-
.vote_on_story(data) ⇒ Object
-
.votes_on_story(options = {}) ⇒ Object
Class Method Details
.author_profile(author_id) ⇒ Object
118
119
120
|
# File 'lib/quintype/api.rb', line 118
def author_profile(author_id)
_get("author/#{author_id}")
end
|
.authors(params) ⇒ Object
114
115
116
|
# File 'lib/quintype/api.rb', line 114
def authors(params)
_get("authors", params)
end
|
.bulk_post(params) ⇒ Object
22
23
24
|
# File 'lib/quintype/api.rb', line 22
def bulk_post(params)
_post("bulk", params)
end
|
.check_email(email) ⇒ Object
146
147
148
|
# File 'lib/quintype/api.rb', line 146
def check_email(email)
_get("member/check", { email: email })
end
|
59
60
61
62
63
|
# File 'lib/quintype/api.rb', line 59
def comments_and_likes(story_ids)
if story_ids.present?
_get("comments-and-votes/" + story_ids.join('|'))
end
end
|
.config ⇒ Object
26
27
28
|
# File 'lib/quintype/api.rb', line 26
def config
_get("config")
end
|
.conn ⇒ Object
18
19
20
|
# File 'lib/quintype/api.rb', line 18
def conn
@@conn
end
|
106
107
108
|
# File 'lib/quintype/api.rb', line 106
def contact_publisher(params)
_post("emails/contact", params)
end
|
.establish_connection(host, conn = Faraday.new(url: host)) ⇒ Object
12
13
14
15
16
|
# File 'lib/quintype/api.rb', line 12
def establish_connection(host, conn = Faraday.new(url: host))
@@host = host
@@api_base = host + '/api/'
@@conn = conn
end
|
.forgot_password(member) ⇒ Object
168
169
170
|
# File 'lib/quintype/api.rb', line 168
def forgot_password(member)
_post("member/forgot-password", member)
end
|
142
143
144
|
# File 'lib/quintype/api.rb', line 142
def get_member_metadata(session_cookie)
_get("member/metadata", {}, { auth_token: session_cookie})
end
|
.invite_users(emails, from_email, from_name) ⇒ Object
98
99
100
101
102
103
104
|
# File 'lib/quintype/api.rb', line 98
def invite_users(emails, from_email, from_name)
params = { emails: emails }
params['from-email'] = from_email if from_email.present?
params['from-name'] = from_name if from_name.present?
_post("emails/invite", params)
end
|
.login(provider, data) ⇒ Object
158
159
160
161
162
|
# File 'lib/quintype/api.rb', line 158
def login(provider, data)
user, = ("login/#{provider}", data)
user['auth_token'] = ['X-QT-AUTH']
user['member'].merge(user.except('member'))
end
|
.login_member(auth) ⇒ Object
154
155
156
|
# File 'lib/quintype/api.rb', line 154
def login_member(auth)
_post("member/login", auth)
end
|
.logout ⇒ Object
164
165
166
|
# File 'lib/quintype/api.rb', line 164
def logout
_get("logout")
end
|
89
90
91
92
93
94
95
96
|
# File 'lib/quintype/api.rb', line 89
def (story_content_id, text, =nil, session_cookie)
hash = {
"story-content-id" => story_content_id,
"text" => text
}
hash.merge!("parent-comment-id" => .to_i) if
_post("comment", hash, session_cookie)
end
|
46
47
48
49
50
51
52
|
# File 'lib/quintype/api.rb', line 46
def related_stories(story_id, section, fields = [])
_get("related-stories?", {
"story-id" => story_id,
section: section,
fields: make_fields(fields)
})
end
|
.reset_password(params) ⇒ Object
172
173
174
|
# File 'lib/quintype/api.rb', line 172
def reset_password(params)
_post("member/password", params)
end
|
138
139
140
|
# File 'lib/quintype/api.rb', line 138
def save_member_metadata(metadata, session_cookie)
_post("member/metadata", { metadata: metadata }, session_cookie)
end
|
.search(options) ⇒ Object
122
123
124
|
# File 'lib/quintype/api.rb', line 122
def search(options)
_get("search", options)
end
|
.search_story_collection(name, options) ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/quintype/api.rb', line 73
def search_story_collection(name, options)
_get("story-collection", {
name: name,
type: "search",
fields: "author-name,hero-image-s3-key,hero-image-metadata,hero-image-caption,headline,slug,sections,metadata"
}.merge(options))
end
|
.sections ⇒ Object
30
31
32
|
# File 'lib/quintype/api.rb', line 30
def sections
_get("sections")
end
|
.signup_member(member) ⇒ Object
150
151
152
|
# File 'lib/quintype/api.rb', line 150
def signup_member(member)
_post("member", member)
end
|
.stories(params, options = {}) ⇒ Object
54
55
56
57
|
# File 'lib/quintype/api.rb', line 54
def stories(params, options = {})
url = options[:facets] ? "stories-with-facets" : "stories"
_get(url, params)
end
|
.story(story_id) ⇒ Object
34
35
36
|
# File 'lib/quintype/api.rb', line 34
def story(story_id)
_get("stories/#{story_id}")
end
|
.story_by_slug(slug, params = {}) ⇒ Object
42
43
44
|
# File 'lib/quintype/api.rb', line 42
def story_by_slug(slug, params = {})
_get("stories-by-slug", params.merge({ slug: slug }))
end
|
.story_collection(options) ⇒ Object
81
82
83
|
# File 'lib/quintype/api.rb', line 81
def story_collection(options)
_get("story-collection", options)
end
|
.story_collection_by_tag(options) ⇒ Object
85
86
87
|
# File 'lib/quintype/api.rb', line 85
def story_collection_by_tag(options)
_get("story-collection/find-by-tag", options)
end
|
.subscribe(member, profile, payment) ⇒ Object
126
127
128
129
130
131
132
|
# File 'lib/quintype/api.rb', line 126
def subscribe(member, profile, payment)
_post("subscribe", {
member: member,
profile: profile,
payment: payment
})
end
|
.tag_by_name(tag_name) ⇒ Object
38
39
40
|
# File 'lib/quintype/api.rb', line 38
def tag_by_name(tag_name)
_get("tag/#{tag_name}")
end
|
.unsubscribe(options) ⇒ Object
134
135
136
|
# File 'lib/quintype/api.rb', line 134
def unsubscribe(options)
_post("unsubscribe", { options: options })
end
|
.unsubscribe_publisher(params) ⇒ Object
110
111
112
|
# File 'lib/quintype/api.rb', line 110
def unsubscribe_publisher(params)
_post("emails/unsubscribe", params)
end
|
.videos ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/quintype/api.rb', line 65
def videos
_get("stories-by-template", {
template: "video",
limit: 12,
fields: "hero-image-s3-key,hero-image-metadata,hero-image-caption,headline,slug"
})
end
|
.vote_on_story(data) ⇒ Object
176
177
178
|
# File 'lib/quintype/api.rb', line 176
def vote_on_story (data)
_post("stories/#{data[:story_id]}/votes", data)
end
|
.votes_on_story(options = {}) ⇒ Object
180
181
182
|
# File 'lib/quintype/api.rb', line 180
def votes_on_story (options = {})
_get("stories/#{story_id}/votes", options)
end
|