Class: DevRuby::Resources::ListingsResource
Instance Attribute Summary
Attributes inherited from BaseResource
#client
Instance Method Summary
collapse
#initialize
Instance Method Details
#create(**body) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/dev_ruby/resources/listings_resource.rb', line 22
def create(**body)
response = post_request('listings', body: { listing: body })
if Helpers.expected_response?(response, 201)
listing = DevRuby::Objects::Listing.new(response.body)
Success(listing)
else
Failure(error_parser(response))
end
end
|
#find(id) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/dev_ruby/resources/listings_resource.rb', line 50
def find(id)
response = get_request("listings/#{id}")
if Helpers.expected_response?(response, 200)
listing = DevRuby::Objects::Listing.new(response.body)
Success(listing)
else
Failure(error_parser(response))
end
end
|
#published(**params) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/dev_ruby/resources/listings_resource.rb', line 6
def published(**params)
params = (params)
response = get_request('listings', params: params)
if Helpers.expected_response?(response, 200)
collection = Collection.from_response(response: response,
type: DevRuby::Objects::Listing,
params: params)
Success(collection)
else
Failure(error_parser(response))
end
end
|
#published_by_category(category:, **params) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/dev_ruby/resources/listings_resource.rb', line 34
def published_by_category(category:, **params)
params = (params)
response = get_request("listings/category/#{category}", params: params)
if Helpers.expected_response?(response, 200)
collection = Collection.from_response(response: response,
type: DevRuby::Objects::Listing,
params: params)
Success(collection)
else
Failure(error_parser(response))
end
end
|
#update(id:, **body) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/dev_ruby/resources/listings_resource.rb', line 62
def update(id:, **body)
response = put_request("listings/#{id}", body: { listing: body })
if Helpers.expected_response?(response, 200)
listing = DevRuby::Objects::Listing.new(response.body)
Success(listing)
else
Failure(error_parser(response))
end
end
|