class Square::APIResource

Public Class Methods

data_type(data_type = nil) click to toggle source

Set a data_type property for this resource.

@param data_type [Square::DataType] Data type. Optional.

@return [Square::DataType]

# File lib/square/api_resource.rb, line 8
def self.data_type(data_type = nil)
  if !data_type.nil?
    @data_type = data_type
  end

  @data_type
end
endpoint_base(base = nil) click to toggle source

Set an endpoint base for this resource.

@param base [String] API endpoint. Optional.

@return [String]

# File lib/square/api_resource.rb, line 21
def self.endpoint_base(base = nil)
  if !base.nil?
    @endpoint_base = base
  end

  @endpoint_base
end
nested_under(parent = nil) click to toggle source

Set a property for nested resources.

@param parent [String] API 'parent' endpoint. Optional.

@return [String]

# File lib/square/api_resource.rb, line 34
def self.nested_under(parent = nil)
  if !parent.nil?
    @nested_under = parent
  end

  @nested_under
end

Private Class Methods

generate_endpoint_url(*args) click to toggle source

Generate an endpoint based on provided arguments.

@param id [String] Resource ID. Optional. @param parent_id [String] ID of the 'parent' resource. Optional.

@return [String] Endpoint URL.

# File lib/square/api_resource.rb, line 50
def self.generate_endpoint_url(*args)
  id, parent_id = args
  File.join([@nested_under, parent_id, @endpoint_base, id].compact)
end