Class: Pixela::Client

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

Defined Under Namespace

Modules: GraphMethods, PixelMethods, UserMethods, WebhookMethods

Constant Summary collapse

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

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 PixelMethods

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

Methods included from GraphMethods

#create_graph, #delete_graph, #get_graph_stats, #get_graphs, #get_pixel_dates, #graph_url, #graphs_url, #update_graph

Constructor Details

#initialize(username:, token:) ⇒ Client


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

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

Instance Attribute Details

#usernameString (readonly)


17
18
19
# File 'lib/pixela/client.rb', line 17

def username
  @username
end

Instance Method Details

#graph(graph_id) ⇒ Pixela::Graph


35
36
37
# File 'lib/pixela/client.rb', line 35

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

#inspectString


27
28
29
30
# File 'lib/pixela/client.rb', line 27

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

#webhook(webhook_hash) ⇒ Pixela::Webhook


42
43
44
# File 'lib/pixela/client.rb', line 42

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