Class: Podio::OAuthClient

Inherits:
ActivePodio::Base show all
Includes:
ActivePodio::Updatable
Defined in:
lib/podio/models/o_auth_client.rb

Overview

Instance Attribute Summary

Attributes inherited from ActivePodio::Base

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActivePodio::Updatable

#remove_nil_values, #update_attributes

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

Class Method Details

.create(attributes) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/podio/models/o_auth_client.rb', line 25

def create(attributes)
  response = Podio.connection.post do |req|
    req.url "/oauth/client/"
    req.body = attributes
  end

  response.body['auth_client_id']
end

.create_admin(user_id, attributes) ⇒ Object



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

def create_admin(user_id, attributes)
  response = Podio.connection.post do |req|
    req.url "/oauth/client/user/#{user_id}/"
    req.body = attributes
  end

  response.status
end

.delete(id) ⇒ Object



61
62
63
64
65
# File 'lib/podio/models/o_auth_client.rb', line 61

def delete(id)``
  response = Podio.connection.delete("/oauth/client/#{id}")

  response.status
end

.delete_grant(id) ⇒ Object



67
68
69
70
71
# File 'lib/podio/models/o_auth_client.rb', line 67

def delete_grant(id)
   response = Podio.connection.delete("/oauth/grant/client/#{id}")

   response.status
end

.find(client_id) ⇒ Object



90
91
92
# File 'lib/podio/models/o_auth_client.rb', line 90

def find(client_id)
  member Podio.connection.get("oauth/client/#{client_id}").body
end

.find_all_for_current_userObject



82
83
84
# File 'lib/podio/models/o_auth_client.rb', line 82

def find_all_for_current_user()
  list Podio.connection.get("oauth/client/").body
end

.find_all_for_user(user_id) ⇒ Object



86
87
88
# File 'lib/podio/models/o_auth_client.rb', line 86

def find_all_for_user(user_id)
  list Podio.connection.get("oauth/client/user/#{user_id}/").body
end

.find_granted_clientsObject



78
79
80
# File 'lib/podio/models/o_auth_client.rb', line 78

def find_granted_clients()
  list Podio.connection.get("oauth/grant/client/").body
end

.reset(id) ⇒ Object



73
74
75
76
# File 'lib/podio/models/o_auth_client.rb', line 73

def reset(id)
  response = Podio.connection.post("/oauth/client/#{id}/reset")
  response.status
end

.update(id, attributes) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/podio/models/o_auth_client.rb', line 43

def update(id, attributes)
  response = Podio.connection.put do |req|
    req.url "/oauth/client/#{id}"
    req.body = attributes
  end

  response.status
end

.update_admin(id, attributes) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/podio/models/o_auth_client.rb', line 52

def update_admin(id, attributes)
  response = Podio.connection.put do |req|
    req.url "/oauth/client/#{id}/admin"
    req.body = attributes
  end

  response.status
end

Instance Method Details

#createObject



16
17
18
# File 'lib/podio/models/o_auth_client.rb', line 16

def create
  self.auth_client_id = self.class.create(attributes)
end

#updateObject



20
21
22
# File 'lib/podio/models/o_auth_client.rb', line 20

def update
  self.class.update(self.auth_client_id, attributes)
end