Class: Podio::Hook

Inherits:
ActivePodio::Base show all
Defined in:
lib/podio/models/hook.rb

Overview

Instance Attribute Summary collapse

Attributes inherited from ActivePodio::Base

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ActivePodio::Base

#==, #[], #[]=, #api_friendly_ref_type, #as_json, collection, delegate_to_hash, has_many, has_one, #hash, #initialize, #initialize_attributes, klass_from_string, list, member, #new_record?, output_attribute_as_json, #parent_model, #persisted?, property, #to_param

Constructor Details

This class inherits a constructor from ActivePodio::Base

Instance Attribute Details

#hookable_idObject

Returns the value of attribute hookable_id.



10
11
12
# File 'lib/podio/models/hook.rb', line 10

def hookable_id
  @hookable_id
end

#hookable_typeObject

Returns the value of attribute hookable_type.



10
11
12
# File 'lib/podio/models/hook.rb', line 10

def hookable_type
  @hookable_type
end

Class Method Details

.create(hookable_type, hookable_id, attributes) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/podio/models/hook.rb', line 19

def create(hookable_type, hookable_id, attributes)
  response = Podio.connection.post do |req|
    req.url "/hook/#{hookable_type}/#{hookable_id}/"
    req.body = {:url => attributes[:url], :type => attributes[:type]}
  end

  response.body['hook_id']
end

.delete(hook_id) ⇒ Object



44
45
46
47
48
# File 'lib/podio/models/hook.rb', line 44

def delete(hook_id)
  Podio.connection.delete do |req|
    req.url "/hook/#{hook_id}"
  end
end

.find_all_for(hookable_type, hookable_id) ⇒ Object



51
52
53
# File 'lib/podio/models/hook.rb', line 51

def find_all_for(hookable_type, hookable_id)
  list Podio.connection.get("/hook/#{hookable_type}/#{hookable_id}/").body
end

.validate(hook_id, code) ⇒ Object



36
37
38
39
40
41
# File 'lib/podio/models/hook.rb', line 36

def validate(hook_id, code)
  Podio.connection.post do |req|
    req.url "/hook/#{hook_id}/verify/validate"
    req.body = {:code => code}
  end
end

.verify(hook_id) ⇒ Object



29
30
31
32
33
# File 'lib/podio/models/hook.rb', line 29

def verify(hook_id)
  Podio.connection.post do |req|
    req.url "/hook/#{hook_id}/verify/request"
  end
end

Instance Method Details

#createObject



13
14
15
# File 'lib/podio/models/hook.rb', line 13

def create
  self.hook_id = self.class.create(self.hookable_type, self.hookable_id, attributes)
end