Class: Socialmod::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/socialmod/callback.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Callback

Returns a new instance of Callback.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/socialmod/callback.rb', line 13

def initialize(params)
  @params    = params
  @id        = params['id']
  @timestamp = params['timestamp']
  @custom_id = params['custom_id']
  @state     = params['state']
  @signature = params['signature']
  @time      = Time.at(@timestamp.to_i)
  @data      = params['data']
  @src       = params['src']
end

Instance Attribute Details

#custom_idObject (readonly)

Returns the value of attribute custom_id.



3
4
5
# File 'lib/socialmod/callback.rb', line 3

def custom_id
  @custom_id
end

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/socialmod/callback.rb', line 3

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/socialmod/callback.rb', line 3

def id
  @id
end

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/socialmod/callback.rb', line 3

def params
  @params
end

#signatureObject (readonly)

Returns the value of attribute signature.



3
4
5
# File 'lib/socialmod/callback.rb', line 3

def signature
  @signature
end

#srcObject (readonly)

Returns the value of attribute src.



3
4
5
# File 'lib/socialmod/callback.rb', line 3

def src
  @src
end

#stateObject (readonly)

Returns the value of attribute state.



3
4
5
# File 'lib/socialmod/callback.rb', line 3

def state
  @state
end

#timeObject (readonly)

Returns the value of attribute time.



3
4
5
# File 'lib/socialmod/callback.rb', line 3

def time
  @time
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



3
4
5
# File 'lib/socialmod/callback.rb', line 3

def timestamp
  @timestamp
end

Instance Method Details

#deferred?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/socialmod/callback.rb', line 37

def deferred?
  state == 'deferred'
end

#failed?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/socialmod/callback.rb', line 33

def failed?
  state == 'failed'
end

#itemObject



41
42
43
# File 'lib/socialmod/callback.rb', line 41

def item
  id && Socialmod::Item.find(id)
end

#passed?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/socialmod/callback.rb', line 29

def passed?
  state == 'passed'
end

#valid?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/socialmod/callback.rb', line 25

def valid?
  hmac == @signature
end