Class: StatusUpdateRequest

Inherits:
Struct
  • Object
show all
Defined in:
lib/dto/status/status_update_request.rb

Overview

Class StatusUpdateRequest returns the correct string for request 3taps

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

from_array, from_hash

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes

Returns:

  • (Object)

    the current value of attributes



3
4
5
# File 'lib/dto/status/status_update_request.rb', line 3

def attributes
  @attributes
end

#errorsObject

Returns the value of attribute errors

Returns:

  • (Object)

    the current value of errors



3
4
5
# File 'lib/dto/status/status_update_request.rb', line 3

def errors
  @errors
end

#eventObject

Returns the value of attribute event

Returns:

  • (Object)

    the current value of event



3
4
5
# File 'lib/dto/status/status_update_request.rb', line 3

def event
  @event
end

#timestumpObject

Returns the value of attribute timestump

Returns:

  • (Object)

    the current value of timestump



3
4
5
# File 'lib/dto/status/status_update_request.rb', line 3

def timestump
  @timestump
end

Instance Method Details

#attributes_for_paramsObject

Method attributes_for_params creates array attributes for params.



17
18
19
# File 'lib/dto/status/status_update_request.rb', line 17

def attributes_for_params
  attributes.collect{ |key, value| "#{key}:'#{CGI.escape value}'"  }.join(", ")
end

#errors_for_paramsObject

Method errors_for_params array errors for params.



23
24
25
# File 'lib/dto/status/status_update_request.rb', line 23

def errors_for_params
  errors.collect{ |error| "{code:#{error.code}, message:'#{CGI.escape error.message}'}" }.join(", ")
end

#to_paramsObject

Method to_params creates the correct string for request 3taps.



7
8
9
10
11
12
13
# File 'lib/dto/status/status_update_request.rb', line 7

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