Class: DevRuby::Resources::OrganizationsResource

Inherits:
BaseResource
  • Object
show all
Defined in:
lib/dev_ruby/resources/organizations_resource.rb

Instance Attribute Summary

Attributes inherited from BaseResource

#client

Instance Method Summary collapse

Methods inherited from BaseResource

#initialize

Constructor Details

This class inherits a constructor from DevRuby::Resources::BaseResource

Instance Method Details

#all_articles_by_username(username:, **params) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/dev_ruby/resources/organizations_resource.rb', line 50

def all_articles_by_username(username:, **params)
  params = to_default_pagination_params(params)

  response = get_request("organizations/#{username}/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

#all_listings_by_username(username:, **params) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/dev_ruby/resources/organizations_resource.rb', line 34

def all_listings_by_username(username:, **params)
  params = to_default_pagination_params(params)

  response = get_request("organizations/#{username}/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

#all_users_by_username(username:, **params) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dev_ruby/resources/organizations_resource.rb', line 18

def all_users_by_username(username:, **params)
  params = to_default_pagination_params(params)

  response = get_request("organizations/#{username}/users", params: params)

  if Helpers.expected_response?(response, 200)
    collection = Collection.from_response(response: response,
                                          type: DevRuby::Objects::User,
                                          params: params)

    Success(collection)
  else
    Failure(error_parser(response))
  end
end

#find_by_username(username) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/dev_ruby/resources/organizations_resource.rb', line 6

def find_by_username(username)
  response = get_request("organizations/#{username}")

  if Helpers.expected_response?(response, 200)
    organization = DevRuby::Objects::Organization.new(response.body)

    Success(organization)
  else
    Failure(error_parser(response))
  end
end