Class: Levelup::Requests::ListLocations

Inherits:
Base show all
Includes:
Templates::MerchantAuthenticated
Defined in:
lib/levelup/requests/list_locations.rb

Overview

Represents a request to list all locations under a specified merchant. This is a v14 endpoint and should not be expected to remain functional indefinitely.

Constant Summary

Constants inherited from Base

Base::ALLOWED_REQUEST_METHODS

Instance Attribute Summary

Attributes included from Templates::MerchantAuthenticated

#merchant_access_token

Instance Method Summary collapse

Methods inherited from Base

#body, #headers, instance_variables_excluded_from_hash, #send_to_api

Methods inherited from Templates::DataParcel

excluded?, #initialize, instance_variables_excluded_from_hash

Constructor Details

This class inherits a constructor from Levelup::Templates::DataParcel

Instance Method Details

#auth_typeObject



8
9
10
# File 'lib/levelup/requests/list_locations.rb', line 8

def auth_type
  :merchant_v14
end

#response_from_hash(hash) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/levelup/requests/list_locations.rb', line 12

def response_from_hash(hash)
  if hash.nil? # no locations found for this merchant
    Responses::Success.new(locations: [])
  else
    locations =
      hash.map { |location| OpenStruct.new(location['location']) }
    Responses::Success.new(locations: locations)
  end
end