Class: Pixela::Client

Inherits:
Object
  • Object
show all
Includes:
GraphMethods, PixelMethods, UserMethods
Defined in:
lib/pixela/client.rb

Defined Under Namespace

Modules: GraphMethods, PixelMethods, UserMethods

Constant Summary collapse

API_ENDPOINT =
"https://pixe.la/v1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from UserMethods

#create_user, #delete_user, #update_user

Methods included from PixelMethods

#create_pixel, #decrement_pixel, #delete_pixel, #get_pixel, #increment_pixel, #update_pixel

Methods included from GraphMethods

#create_graph, #delete_graph, #get_graphs, #graph_url, #update_graph

Constructor Details

#initialize(username:, token:) ⇒ Client

Returns a new instance of Client.

Parameters:

  • username (String)
  • token (String)

    secret token



19
20
21
22
# File 'lib/pixela/client.rb', line 19

def initialize(username:, token:)
  @username = username
  @token    = token
end

Instance Attribute Details

#usernameString (readonly)

Returns:

  • (String)


15
16
17
# File 'lib/pixela/client.rb', line 15

def username
  @username
end

Instance Method Details

#graph(graph_id) ⇒ Pixela::Graph

Parameters:

  • graph_id (String)

Returns:



33
34
35
# File 'lib/pixela/client.rb', line 33

def graph(graph_id)
  Graph.new(client: self, graph_id: graph_id)
end

#inspectString

Returns:

  • (String)


25
26
27
28
# File 'lib/pixela/client.rb', line 25

def inspect
  # NOTE: hide @token
  %Q(#<Pixela::Client:0x#{"%016X" % object_id} @username="#{username}">)
end