Class: DistritoTracking::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/distrito_tracking/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



10
11
12
13
14
15
16
# File 'lib/distrito_tracking/client.rb', line 10

def initialize
  @client = Aws::SNS::Client.new(
    region: configuration.region,
    access_key_id: configuration.access_key_id,
    secret_access_key: configuration.secret_access_key
  )
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/distrito_tracking/client.rb', line 8

def client
  @client
end

#configurationObject (readonly)

Returns the value of attribute configuration.



8
9
10
# File 'lib/distrito_tracking/client.rb', line 8

def configuration
  @configuration
end

Instance Method Details

#inspectObject



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

def inspect
  "#<DistritoTracking::Client>"
end

#publish(data) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/distrito_tracking/client.rb', line 18

def publish(data)
  return false if data.empty?

  client.publish({
                   topic_arn: configuration.topic_arn,
                   message: JSON.generate(data)
                 })
end