Class: DevRuby::Resources::ArticlesResource
Instance Attribute Summary collapse
Instance Method Summary
collapse
#initialize
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
7
8
9
|
# File 'lib/dev_ruby/resources/articles_resource.rb', line 7
def client
@client
end
|
Instance Method Details
#create(**body) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/dev_ruby/resources/articles_resource.rb', line 25
def create(**body)
response = post_request('articles', body: { article: body })
if Helpers.expected_response?(response, 201)
article = DevRuby::Objects::Article.new(response.body)
Success(article)
else
Failure(error_parser(response))
end
end
|
#find(id) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/dev_ruby/resources/articles_resource.rb', line 53
def find(id)
response = get_request("articles/#{id}")
if Helpers.expected_response?(response, 200)
article = DevRuby::Objects::Article.new(response.body)
Success(article)
else
Failure(error_parser(response))
end
end
|
#find_by_path(username:, slug:) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/dev_ruby/resources/articles_resource.rb', line 77
def find_by_path(username:, slug:)
response = get_request("articles/#{username}/#{slug}")
if Helpers.expected_response?(response, 200)
article = DevRuby::Objects::Article.new(response.body)
Success(article)
else
Failure(error_parser(response))
end
end
|
#latest_published(**params) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/dev_ruby/resources/articles_resource.rb', line 37
def latest_published(**params)
params = (params)
response = get_request('articles/latest', params: params)
if Helpers.expected_response?(response, 200)
collection = Collection.from_response(response: response,
type: DevRuby::Objects::Article,
params: params)
Success(collection)
else
Failure(error_parser(response))
end
end
|
#me ⇒ Object
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/dev_ruby/resources/articles_resource.rb', line 89
def me
response = get_request('articles/me')
if Helpers.expected_response?(response, 200)
article = DevRuby::Objects::Article.new(response.body)
Success(article)
else
Failure(error_parser(response))
end
end
|
#me_all(**params) ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/dev_ruby/resources/articles_resource.rb', line 133
def me_all(**params)
params = (params)
response = get_request('articles/me/all', params: params)
if Helpers.expected_response?(response, 200)
collection = Collection.from_response(response: response,
type: DevRuby::Objects::Article,
params: params)
Success(collection)
else
Failure(error_parser(response))
end
end
|
#me_published(**params) ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/dev_ruby/resources/articles_resource.rb', line 101
def me_published(**params)
params = (params)
response = get_request('articles/me/published', params: params)
if Helpers.expected_response?(response, 200)
collection = Collection.from_response(response: response,
type: DevRuby::Objects::Article,
params: params)
Success(collection)
else
Failure(error_parser(response))
end
end
|
#me_unpublished(**params) ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/dev_ruby/resources/articles_resource.rb', line 117
def me_unpublished(**params)
params = (params)
response = get_request('articles/me/unpublished', params: params)
if Helpers.expected_response?(response, 200)
collection = Collection.from_response(response: response,
type: DevRuby::Objects::Article,
params: params)
Success(collection)
else
Failure(error_parser(response))
end
end
|
#published(**params) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/dev_ruby/resources/articles_resource.rb', line 9
def published(**params)
params = (params)
response = get_request('articles', params: params)
if Helpers.expected_response?(response, 200)
collection = Collection.from_response(response: response,
type: DevRuby::Objects::Article,
params: params)
Success(collection)
else
Failure(error_parser(response))
end
end
|
#update(id, **body) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/dev_ruby/resources/articles_resource.rb', line 65
def update(id, **body)
response = put_request("articles/#{id}", body: { article: body })
if Helpers.expected_response?(response, 200)
article = DevRuby::Objects::Article.new(response.body)
Success(article)
else
Failure(error_parser(response))
end
end
|
#videos(**params) ⇒ Object
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# File 'lib/dev_ruby/resources/articles_resource.rb', line 149
def videos(**params)
params = (params)
response = get_request('videos', params: params)
if Helpers.expected_response?(response, 200)
collection = Collection.from_response(response: response,
type: DevRuby::Objects::Article,
params: params)
Success(collection)
else
Failure(error_parser(response))
end
end
|