Class: MyTankInfo::Client

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

Constant Summary collapse

BASE_URL =
"https://app.mytankinfo.com"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
# File 'lib/my_tank_info/client.rb', line 11

def initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil)
  @api_key = api_key
  @adapter = adapter
  @stubs = stubs
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



9
10
11
# File 'lib/my_tank_info/client.rb', line 9

def api_key
  @api_key
end

Instance Method Details

#active_alarmsObject



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

def active_alarms
  ActiveAlarmsResource.new(self)
end

#alarm_historyObject



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

def alarm_history
  AlarmHistoryResource.new(self)
end

#alarm_notesObject



29
30
31
# File 'lib/my_tank_info/client.rb', line 29

def alarm_notes
  AlarmNotesResource.new(self)
end

#connectionObject



97
98
99
100
101
102
103
104
# File 'lib/my_tank_info/client.rb', line 97

def connection
  @connection ||= Faraday.new do |conn|
    conn.url_prefix = BASE_URL
    conn.request :json
    conn.response :json, content_type: "application/json"
    conn.adapter @adapter, @stubs
  end
end

#csld_resultsObject



41
42
43
# File 'lib/my_tank_info/client.rb', line 41

def csld_results
  CsldResultsResource.new(self)
end

#environmental_sitegroupsObject



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

def environmental_sitegroups
  EnvironmentalSitegroupsResource.new(self)
end

#generate_api_token(username:, password:) ⇒ Object



93
94
95
# File 'lib/my_tank_info/client.rb', line 93

def generate_api_token(username:, password:)
  TokensResource.new(self).generate(username: username, password: password)
end

#inventory_sitegroupsObject



49
50
51
# File 'lib/my_tank_info/client.rb', line 49

def inventory_sitegroups
  InventorySitegroupsResource.new(self)
end

#line_leak_resultsObject



37
38
39
# File 'lib/my_tank_info/client.rb', line 37

def line_leak_results
  LineLeakResultsResource.new(self)
end

#notification_contactsObject



85
86
87
# File 'lib/my_tank_info/client.rb', line 85

def notification_contacts
  NotificationContactsResource.new(self)
end

#notification_rulesObject



89
90
91
# File 'lib/my_tank_info/client.rb', line 89

def notification_rules
  NotificationRulesResource.new(self)
end

#sensor_status_resultsObject



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

def sensor_status_results
  SensorStatusResultsResource.new(self)
end

#sitegroup_inventory_dashboardsObject



57
58
59
# File 'lib/my_tank_info/client.rb', line 57

def sitegroup_inventory_dashboards
  SitegroupInventoryDashboardsResource.new(self)
end

#tank_daily_usageObject



61
62
63
# File 'lib/my_tank_info/client.rb', line 61

def tank_daily_usage
  TankDailyUsageResource.new(self)
end

#tank_deliveriesObject



65
66
67
# File 'lib/my_tank_info/client.rb', line 65

def tank_deliveries
  TankDeliveriesResource.new(self)
end

#tank_inventoryObject



69
70
71
# File 'lib/my_tank_info/client.rb', line 69

def tank_inventory
  TankInventoryResource.new(self)
end

#tank_leak_resultsObject



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

def tank_leak_results
  TankLeakResultsResource.new(self)
end

#tank_reconciliation_recordsObject



81
82
83
# File 'lib/my_tank_info/client.rb', line 81

def tank_reconciliation_records
  TankReconciliationRecordsResource.new(self)
end

#tank_rulesObject



77
78
79
# File 'lib/my_tank_info/client.rb', line 77

def tank_rules
  TankRulesResource.new(self)
end

#tank_runoutObject



73
74
75
# File 'lib/my_tank_info/client.rb', line 73

def tank_runout
  TankRunoutResource.new(self)
end

#tanksObject



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

def tanks
  TanksResource.new(self)
end