Class: Pixela::Client

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

Defined Under Namespace

Modules: ChannelMethods, GraphMethods, NotificationMethods, 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 NotificationMethods

#create_notification, #delete_notification, #get_notifications, #update_notification

Methods included from GraphMethods

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

Methods included from ChannelMethods

#create_channel, #create_slack_channel, #delete_channel, #get_channels, #update_channel, #update_slack_channel

Constructor Details

#initialize(username:, token:) ⇒ Client

Returns a new instance of Client.

Parameters:

  • username (String)
  • token (String)

    secret token



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

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

Instance Attribute Details

#usernameString (readonly)

Returns:

  • (String)


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

def username
  @username
end

Instance Method Details

#channel(channel_id) ⇒ Pixela::Channel

Parameters:

  • channel_id (String)

Returns:



53
54
55
# File 'lib/pixela/client.rb', line 53

def channel(channel_id)
  Channel.new(client: self, channel_id: channel_id)
end

#graph(graph_id) ⇒ Pixela::Graph

Parameters:

  • graph_id (String)

Returns:



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

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

#inspectString

Returns:

  • (String)


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

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:



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

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