Class: Agree2::User

Inherits:
Object
  • Object
show all
Defined in:
lib/agree2/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, key, secret) ⇒ User

Returns a new instance of User.



5
6
7
8
# File 'lib/agree2/user.rb', line 5

def initialize(client,key,secret)
  @client=client
  @access_token=OAuth::AccessToken.new @client.consumer,key,secret
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



4
5
6
# File 'lib/agree2/user.rb', line 4

def access_token
  @access_token
end

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/agree2/user.rb', line 4

def client
  @client
end

Instance Method Details

#agreementsObject



10
11
12
# File 'lib/agree2/user.rb', line 10

def agreements
  @agreements||=Agree2::ProxyCollection.new self,'/agreements','Agreement'
end

#delete(path, options = {}) ⇒ Object



34
35
36
# File 'lib/agree2/user.rb', line 34

def delete(path,options={})
  handle_response @access_token.delete(path,options)
end

#get(path, options = {}) ⇒ Object



18
19
20
# File 'lib/agree2/user.rb', line 18

def get(path,options={})
  handle_response @access_token.get(path,{'Accept'=>'application/json'}.merge(options))
end

#head(path, options = {}) ⇒ Object



22
23
24
# File 'lib/agree2/user.rb', line 22

def head(path,options={})
  handle_response @access_token.head(path,options)
end

#pathObject

:nodoc:



50
51
52
# File 'lib/agree2/user.rb', line 50

def path #:nodoc:
  ""
end

#post(path, data = nil, options = {}) ⇒ Object



26
27
28
# File 'lib/agree2/user.rb', line 26

def post(path,data=nil,options={})
  handle_response @access_token.post(path,(data ? data.to_json : nil),AGREE2_JSON_HEADERS.merge(options))
end

#put(path, data = nil, options = {}) ⇒ Object



30
31
32
# File 'lib/agree2/user.rb', line 30

def put(path,data=nil,options={})
  handle_response @access_token.put(path,(data ? data.to_json : nil),AGREE2_JSON_HEADERS.merge(options) )
end

#secretObject

The AccessToken secret



46
47
48
# File 'lib/agree2/user.rb', line 46

def secret
  @access_token.secret
end

#templatesObject



14
15
16
# File 'lib/agree2/user.rb', line 14

def templates
  @templates||=Agree2::ProxyCollection.new self,'/masters','Template'
end

#tokenObject

The AccessToken token



41
42
43
# File 'lib/agree2/user.rb', line 41

def token
  @access_token.token
end