Class: Pinch::Webhook

Inherits:
Object
  • Object
show all
Defined in:
lib/pinch/models/webhook.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = nil, url = nil, webhook_type = nil) ⇒ Webhook

Returns a new instance of Webhook.



18
19
20
21
22
23
24
25
# File 'lib/pinch/models/webhook.rb', line 18

def initialize(id = nil,
               url = nil,
               webhook_type = nil)
  @id = id
  @url = url
  @webhook_type = webhook_type

end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name) ⇒ Object



27
28
29
# File 'lib/pinch/models/webhook.rb', line 27

def method_missing(method_name)
  puts "There is no method called '#{method_name}'."
end

Instance Attribute Details

#idInteger (readonly)

TODO: Write general description for this method

Returns:

  • (Integer)


8
9
10
# File 'lib/pinch/models/webhook.rb', line 8

def id
  @id
end

#urlString

TODO: Write general description for this method

Returns:



12
13
14
# File 'lib/pinch/models/webhook.rb', line 12

def url
  @url
end

#webhook_typeInteger

TODO: Write general description for this method

Returns:

  • (Integer)


16
17
18
# File 'lib/pinch/models/webhook.rb', line 16

def webhook_type
  @webhook_type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/pinch/models/webhook.rb', line 38

def self.from_hash(hash)
  if hash == nil
    nil
  else
    # Extract variables from the hash
    id = hash["id"]
    url = hash["url"]
    webhook_type = hash["webhook_type"]
    # Create object from extracted values
    Webhook.new(id,
                url,
                webhook_type)
  end
end

Instance Method Details

#key_mapObject

Defines the key map for json serialization



54
55
56
57
58
59
60
# File 'lib/pinch/models/webhook.rb', line 54

def key_map
  hash = {}
  hash['id'] = id
  hash['url'] = url
  hash['webhook_type'] = webhook_type
  hash
end

#to_jsonObject

Creates JSON of the curent object



32
33
34
35
# File 'lib/pinch/models/webhook.rb', line 32

def to_json
  hash = key_map
  hash.to_json
end