Class: Pixela::Client

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

Defined Under Namespace

Modules: GraphMethods, PixelMethods, ProfileMethods, UserMethods, WebhookMethods

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WebhookMethods

#create_webhook, #delete_webhook, #get_webhooks, #invoke_webhook

Methods included from UserMethods

#create_user, #delete_user, #update_user

Methods included from ProfileMethods

#update_profile

Methods included from PixelMethods

#add_pixel, #create_pixel, #create_pixels, #decrement_pixel, #delete_pixel, #get_pixel, #increment_pixel, #subtract_pixel, #update_pixel

Methods included from GraphMethods

#create_graph, #delete_graph, #get_graph_def, #get_graph_latest, #get_graph_stats, #get_graphs, #get_pixel_dates, #get_pixels, #graph_url, #graphs_url, #run_stopwatch, #update_graph

Constructor Details

#initialize(username:, token:) ⇒ Client

Returns a new instance of Client.

Parameters:

  • username (String)
  • token (String)

    secret token



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

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

Instance Attribute Details

#usernameString (readonly)

Returns:

  • (String)


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

def username
  @username
end

Instance Method Details

#graph(graph_id) ⇒ Pixela::Graph

Parameters:

  • graph_id (String)

Returns:



38
39
40
# File 'lib/pixela/client.rb', line 38

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

#inspectString

Returns:

  • (String)


30
31
32
33
# File 'lib/pixela/client.rb', line 30

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

#webhook(webhook_hash) ⇒ Pixela::Webhook

Parameters:

  • webhook_hash (String)

Returns:



45
46
47
# File 'lib/pixela/client.rb', line 45

def webhook(webhook_hash)
  Webhook.new(client: self, webhook_hash: webhook_hash)
end