Class: Podio::OAuthClient

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

Instance Attribute Summary

Attributes inherited from ActivePodio::Base

#attributes, #error_code, #error_message, #error_parameters, #error_propagate

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ActivePodio::Base

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

Constructor Details

This class inherits a constructor from ActivePodio::Base

Class Method Details

.create(attributes) ⇒ Object



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

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



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

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



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

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

  response.status
end

.delete_grant(id) ⇒ Object



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

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

   response.status
end

.find(client_id) ⇒ Object



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

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

.find_all_for_current_userObject



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

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

.find_all_for_user(user_id) ⇒ Object



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

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

.find_granted_clientsObject



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

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

.reset(id) ⇒ Object



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

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

.update(id, attributes) ⇒ Object



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

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



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

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



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

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

#updateObject



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

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