Class: Dnsimple::Client::ClientService
- Inherits:
-
Object
- Object
- Dnsimple::Client::ClientService
- Defined in:
- lib/dnsimple/client/clients.rb
Overview
Struct
Direct Known Subclasses
AccountsService, CertificatesService, ContactsService, DomainsService, IdentityService, OauthService, RegistrarService, ServicesService, TemplatesService, TldsService, VanityNameServersService, WebhooksService, ZonesService
Instance Attribute Summary collapse
- #client ⇒ Dnsimple::Client readonly
Instance Method Summary collapse
-
#initialize(client) ⇒ ClientService
constructor
A new instance of ClientService.
-
#paginate(method, *args) ⇒ Dnsimple::CollectionResponse
private
Internal helper that loops over a paginated response and returns all the records in the collection.
Constructor Details
#initialize(client) ⇒ ClientService
Returns a new instance of ClientService.
83 84 85 |
# File 'lib/dnsimple/client/clients.rb', line 83 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Dnsimple::Client (readonly)
81 82 83 |
# File 'lib/dnsimple/client/clients.rb', line 81 def client @client end |
Instance Method Details
#paginate(method, *args) ⇒ Dnsimple::CollectionResponse
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal helper that loops over a paginated response and returns all the records in the collection.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/dnsimple/client/clients.rb', line 94 def paginate(method, *args) current_page = 0 total_pages = nil collection = [] = args.pop response = nil loop do current_page += 1 query = Extra.deep_merge(, query: { page: current_page, per_page: 100 }) response = send(method, *(args + [query])) total_pages ||= response.total_pages collection.concat(response.data) break unless current_page < total_pages end CollectionResponse.new(response.http_response, collection) end |