Class: GreenButtonData::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/green-button-data/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
13
14
15
# File 'lib/green-button-data/client.rb', line 7

def initialize(config)
  @configuration = GreenButtonData::Configuration.new

  config.each do |key, value|
    if @configuration.respond_to? "#{key}="
      @configuration.send "#{key}=", value
    end
  end
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



3
4
5
# File 'lib/green-button-data/client.rb', line 3

def configuration
  @configuration
end

#sslObject

Returns the value of attribute ssl.



3
4
5
# File 'lib/green-button-data/client.rb', line 3

def ssl
  @ssl
end

#tokenObject

Returns the value of attribute token.



3
4
5
# File 'lib/green-button-data/client.rb', line 3

def token
  @token
end

Instance Method Details

#application_information(id = nil, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/green-button-data/client.rb', line 17

def application_information(id = nil, options = {})
  if id.is_a? Hash
    options = id
    id = nil
  end

  get_resource(
    @configuration.application_information_url(id),
    id,
    ApplicationInformation,
    options
  )
end

#authorization(id = nil, options = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/green-button-data/client.rb', line 31

def authorization(id = nil, options = {})
  if id.is_a? Hash
    options = id
    id = nil
  end

  get_resource(
    @configuration.authorization_url(id),
    id,
    Authorization,
    sanitize_options(options)
  )
end

#interval_block(id = nil, options = {}) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/green-button-data/client.rb', line 45

def interval_block(id = nil, options = {})
  if id.is_a? Hash
    options = id
    id = nil
  end

  id ||= options[:interval_block_id]
  meter_reading_id = options[:meter_reading_id]
  usage_point_id = options[:usage_point_id]
  subscription_id = options[:subscription_id]

  get_resource(
    @configuration.interval_block_url(
      interval_block_id: id,
      meter_reading_id: meter_reading_id,
      usage_point_id: usage_point_id,
      subscription_id: subscription_id
    ),
    id,
    IntervalBlock,
    sanitize_options(options)
  )
end

#interval_block_bulk(id = nil, options = {}) ⇒ Object



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/green-button-data/client.rb', line 195

def interval_block_bulk(id = nil, options = {})
  if id.is_a? Hash
    options = id
    id = nil
  end

  subscription_id = options[:subscription_id]
  bulk_file_id = options[:bulk_file_id]

  get_resource(
    @configuration.bulk_url(
      subscription_id: subscription_id,
      bulk_file_id: bulk_file_id
    ),
    id,
    IntervalBlock,
    sanitize_options(options)
  )
end

#local_time_parameters(id = nil, options = {}) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/green-button-data/client.rb', line 69

def local_time_parameters(id = nil, options = {})
  if id.is_a? Hash
    options = id
    id = nil
  end

  get_resource(
    @configuration.local_time_parameters_url(id),
    id,
    LocalTimeParameters,
    sanitize_options(options)
  )
end

#meter_reading(id = nil, options = {}) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/green-button-data/client.rb', line 83

def meter_reading(id = nil, options = {})
  if id.is_a? Hash
    options = id
    id = nil
  end

  id ||= options[:meter_reading_id]
  usage_point_id = options[:usage_point_id]
  subscription_id = options[:subscription_id]

  get_resource(
    @configuration.meter_reading_url(
      meter_reading_id: id,
      usage_point_id: usage_point_id,
      subscription_id: subscription_id
    ),
    id,
    MeterReading,
    sanitize_options(options)
  )
end

#reading_type(id = nil, options = {}) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/green-button-data/client.rb', line 105

def reading_type(id = nil, options = {})
  if id.is_a? Hash
    options = id
    id = nil
  end

  get_resource(
    @configuration.reading_type_url(id),
    id,
    ReadingType,
    sanitize_options(options)
  )
end

#retail_customer(id = nil, options = {}) ⇒ Object



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/green-button-data/client.rb', line 177

def retail_customer(id = nil, options = {})
  if id.is_a? Hash
    options = id
    id = nil
  end

  retail_customer_id = options[:subscription_id]

  get_resource(
    @configuration.retail_customer_url(
      subscription_id: retail_customer_id
    ),
    id,
    RetailCustomer,
    sanitize_options(options)
  )
end

#retail_customer_bulk(id = nil, options = {}) ⇒ Object



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/green-button-data/client.rb', line 235

def retail_customer_bulk(id = nil, options = {})
  if id.is_a? Hash
    options = id
    id = nil
  end

  subscription_id = options[:subscription_id]
  bulk_file_id = options[:bulk_file_id]

  get_resource(
    @configuration.bulk_url(
      subscription_id: subscription_id,
      bulk_file_id: bulk_file_id
    ),
    id,
    RetailCustomer,
    sanitize_options(options)
  )
end

#usage_point(id = nil, options = {}) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/green-button-data/client.rb', line 135

def usage_point(id = nil, options = {})
  if id.is_a? Hash
    options = id
    id = nil
  end

  id ||= options[:usage_point_id]
  subscription_id = options[:subscription_id]

  get_resource(
    @configuration.usage_point_url(
      usage_point_id: id,
      subscription_id: subscription_id
    ),
    id,
    UsagePoint,
    sanitize_options(options)
  )
end

#usage_summary(id = nil, options = {}) ⇒ Object



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/green-button-data/client.rb', line 155

def usage_summary(id = nil, options = {})
  if id.is_a? Hash
    options = id
    id = nil
  end

  id ||= options[:usage_summary_id]
  usage_point_id = options[:usage_point_id]
  subscription_id = options[:subscription_id]

  get_resource(
    @configuration.usage_summary_url(
      usage_summary_id: id,
      usage_point_id: usage_point_id,
      subscription_id: subscription_id
    ),
    id,
    UsageSummary,
    sanitize_options(options)
  )
end

#usage_summary_bulk(id = nil, options = {}) ⇒ Object



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/green-button-data/client.rb', line 215

def usage_summary_bulk(id = nil, options = {})
  if id.is_a? Hash
    options = id
    id = nil
  end

  subscription_id = options[:subscription_id]
  bulk_file_id = options[:bulk_file_id]

  get_resource(
    @configuration.bulk_url(
      subscription_id: subscription_id,
      bulk_file_id: bulk_file_id
    ),
    id,
    UsageSummary,
    sanitize_options(options)
  )
end