Class: PromisePay::Callback

Inherits:
Object
  • Object
show all
Includes:
Lib::DynamicAccessors
Defined in:
lib/promise_pay/callback.rb

Constant Summary collapse

ENDPOINT =
'callbacks/'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Lib::DynamicAccessors

#accessor_defined?, #assign_instance_variables, #define_accessor, #initialize_property, #set_property

Constructor Details

#initialize(options = {}) ⇒ Callback

Returns a new instance of Callback.



31
32
33
34
35
36
37
38
39
40
# File 'lib/promise_pay/callback.rb', line 31

def initialize(options = {})
  @id           = options.fetch(:id) { nil }
  @url          = options.fetch(:url) { "" }
  @description  = options.fetch(:description) { "" }
  @object_type  = options.fetch(:object_type) { "" }
  @enabled      = options.fetch(:enabled) { true }

  @method       = options.fetch(:method)
  @endpoint     = ENDPOINT + @id.to_s
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



12
13
14
# File 'lib/promise_pay/callback.rb', line 12

def description
  @description
end

#enabledObject (readonly)

Returns the value of attribute enabled.



14
15
16
# File 'lib/promise_pay/callback.rb', line 14

def enabled
  @enabled
end

#endpointObject (readonly)

Returns the value of attribute endpoint.



17
18
19
# File 'lib/promise_pay/callback.rb', line 17

def endpoint
  @endpoint
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/promise_pay/callback.rb', line 10

def id
  @id
end

#methodObject (readonly)

Returns the value of attribute method.



16
17
18
# File 'lib/promise_pay/callback.rb', line 16

def method
  @method
end

#object_typeObject (readonly)

Returns the value of attribute object_type.



13
14
15
# File 'lib/promise_pay/callback.rb', line 13

def object_type
  @object_type
end

#urlObject (readonly)

Returns the value of attribute url.



11
12
13
# File 'lib/promise_pay/callback.rb', line 11

def url
  @url
end

Class Method Details

.create(options = {}) ⇒ Object



27
28
29
# File 'lib/promise_pay/callback.rb', line 27

def self.create(options = {})
  new(options.merge(method: :post)).execute
end

.delete(options = {}) ⇒ Object



23
24
25
# File 'lib/promise_pay/callback.rb', line 23

def self.delete(options = {})
  new(options.merge(method: :delete)).execute
end

.index(options = {}) ⇒ Object



19
20
21
# File 'lib/promise_pay/callback.rb', line 19

def self.index(options = {})
  new(options.merge(method: :get)).execute
end

Instance Method Details

#executeObject



42
43
44
45
# File 'lib/promise_pay/callback.rb', line 42

def execute
  assign_instance_variables(result)
  self
end