Class: Brickset::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/brickset/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/brickset/client.rb', line 10

def initialize(options = {})
  # Merge the config values from the module and those passed
  # to the client.
  merged_options = Brickset.options.merge(options)

  # Copy the merged values to this client and ignore those
  # not part of our configuration
  Configuration::VALID_CONFIG_KEYS.each do |key|
    send("#{key}=", merged_options[key])
  end
end

Instance Method Details

#get_recently_updated_sets(minutes_ago) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/brickset/client.rb', line 34

def get_recently_updated_sets minutes_ago
  response = call_api :getRecentlyUpdatedSets, { minutesAgo: minutes_ago }
  if response["ArrayOfSets"].nil?
    []
  else
    response["ArrayOfSets"]["sets"] 
  end
end

#get_sets(options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/brickset/client.rb', line 22

def get_sets options = {}
  required_params = [:userHash, :query, :theme, :subtheme, :setNumber, :year, :owned, :wanted, :orderBy, :pageSize, :pageNumber, :userName]
  default_options = {}
  required_params.each { |param| default_options[param] = nil }
  response = call_api(:getSets, default_options.merge(options))
  if response["ArrayOfSets"].nil?
    []
  else
    response["ArrayOfSets"]["sets"] 
  end
end