Class: Cloudflare::Connection

Inherits:
Representation
  • Object
show all
Defined in:
lib/cloudflare/connection.rb

Instance Method Summary collapse

Methods inherited from Representation

#process_response, #represent, #represent_message, #representation, #to_hash

Instance Method Details

#accountsObject



52
53
54
# File 'lib/cloudflare/connection.rb', line 52

def accounts
  self.with(Accounts, path: 'accounts')
end

#authenticated(token: nil, key: nil, email: nil) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/cloudflare/connection.rb', line 31

def authenticated(token: nil, key: nil, email: nil)
  headers = {}
  
  if token
    headers['Authorization'] = "Bearer #{token}"
  elsif key
    if email
      headers['X-Auth-Key'] = key
      headers['X-Auth-Email'] = email
    else
      headers['X-Auth-User-Service-Key'] = key
    end
  end
  
  self.with(headers: headers)
end

#userObject



56
57
58
# File 'lib/cloudflare/connection.rb', line 56

def user
  self.with(User, path: 'user')
end

#zonesObject



48
49
50
# File 'lib/cloudflare/connection.rb', line 48

def zones
  self.with(Zones, path: 'zones')
end