Sha256: 724ae9e7ee77b0136a577b6aaf3b2d6f702e160e8389413a214e3f6f7572dcd0

Contents?: true

Size: 933 Bytes

Versions: 16

Compression:

Stored size: 933 Bytes

Contents

# Class StatusUpdateRequest returns the correct string for request 3taps
# 
class StatusUpdateRequest < Struct.new(:event, :timestump, :attributes, :errors)  
  #
  # Method +to_params+ creates the correct string for request 3taps.
  #
  def to_params
    data =  "status:'#{event}'"
    data <<  ", timestump:'#{((timestump).utc.to_s(:db)).gsub(/\s/,"+")}'" if timestump
    data <<  ", attributes:{#{attributes_for_params}}" unless attributes.empty?
    data <<  ", errors:[#{errors_for_params}]" unless errors.empty?
    data
  end
  #
  # Method +attributes_for_params+ creates array attributes for params.
  #
  def attributes_for_params
    attributes.collect{ |key, value| "#{key}:'#{CGI.escape value}'"  }.join(", ")
  end
  #
  # Method +errors_for_params+ array errors for params.
  #
  def errors_for_params
    errors.collect{ |error| "{code:#{error.code}, message:'#{CGI.escape error.message}'}" }.join(", ")
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
threetaps-client-1.0.14 lib/dto/status/status_update_request.rb
threetaps-client-1.0.13 lib/dto/status/status_update_request.rb
threetaps-client-1.0.12 lib/dto/status/status_update_request.rb
threetaps-client-1.0.11 lib/dto/status/status_update_request.rb
threetaps-client-1.0.10 lib/dto/status/status_update_request.rb
threetaps-client-1.0.9 lib/dto/status/status_update_request.rb
threetaps-client-1.0.8 lib/dto/status/status_update_request.rb
threetaps-client-1.0.7 lib/dto/status/status_update_request.rb
threetaps-client-1.0.6 lib/dto/status/status_update_request.rb
threetaps-client-1.0.5 lib/dto/status/status_update_request.rb
threetaps-client-1.0.4 lib/dto/status/status_update_request.rb
threetaps-client-1.0.3 lib/dto/status/status_update_request.rb
threetaps-client-1.0.2 lib/dto/status/status_update_request.rb
threetaps-client-1.0.1 lib/dto/status/status_update_request.rb
threetaps-client-1.0.0 lib/dto/status/status_update_request.rb
threetaps-client-0.5.1 lib/dto/status/status_update_request.rb