Module: RestCore::ClientOauth1

Includes:
RestCore
Defined in:
lib/rest-core/client_oauth1.rb

Constant Summary

Constant Summary

Constants included from RestCore

ASYNC, CLIENT, DRY, FAIL, HIJACK, LOG, PROMISE, REQUEST_HEADERS, REQUEST_METHOD, REQUEST_PATH, REQUEST_PAYLOAD, REQUEST_QUERY, REQUEST_URI, RESPONSE_BODY, RESPONSE_HEADERS, RESPONSE_KEY, RESPONSE_SOCKET, RESPONSE_STATUS, TIMER, Universal, VERSION

Instance Method Summary collapse

Methods included from RestCore

eagerload, id

Instance Method Details

#authorize!(opts = {}) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/rest-core/client_oauth1.rb', line 18

def authorize! opts={}
  self.data = ParseQuery.parse_query(
    post(access_token_path, {}, {}, {:json_response => false}.merge(opts)))

  data['authorized'] = 'true'
  data
end

#authorize_urlObject



14
15
16
# File 'lib/rest-core/client_oauth1.rb', line 14

def authorize_url
  url(authorize_path, :oauth_token => oauth_token)
end

#authorize_url!(opts = {}) ⇒ Object



7
8
9
10
11
12
# File 'lib/rest-core/client_oauth1.rb', line 7

def authorize_url! opts={}
  self.data = ParseQuery.parse_query(
    post(request_token_path, {}, {}, {:json_response => false}.merge(opts)))

  authorize_url
end

#authorized?Boolean



26
27
28
# File 'lib/rest-core/client_oauth1.rb', line 26

def authorized?
  !!(oauth_token && oauth_token_secret && data['authorized'])
end

#data_jsonObject



30
31
32
# File 'lib/rest-core/client_oauth1.rb', line 30

def data_json
  Json.encode(data.merge('sig' => calculate_sig))
end

#data_json=(json) ⇒ Object



34
35
36
37
38
# File 'lib/rest-core/client_oauth1.rb', line 34

def data_json= json
  self.data = check_sig_and_return_data(Json.decode(json))
rescue Json.const_get(:ParseError)
  self.data = nil
end

#oauth_callbackObject



52
53
54
# File 'lib/rest-core/client_oauth1.rb', line 52

def oauth_callback
  data['oauth_callback'] if data.kind_of?(Hash)
end

#oauth_callback=(uri) ⇒ Object



55
56
57
# File 'lib/rest-core/client_oauth1.rb', line 55

def oauth_callback= uri
  data['oauth_callback'] = uri if data.kind_of?(Hash)
end

#oauth_tokenObject



40
41
42
# File 'lib/rest-core/client_oauth1.rb', line 40

def oauth_token
  data['oauth_token'] if data.kind_of?(Hash)
end

#oauth_token=(token) ⇒ Object



43
44
45
# File 'lib/rest-core/client_oauth1.rb', line 43

def oauth_token= token
  data['oauth_token'] = token if data.kind_of?(Hash)
end

#oauth_token_secretObject



46
47
48
# File 'lib/rest-core/client_oauth1.rb', line 46

def oauth_token_secret
  data['oauth_token_secret'] if data.kind_of?(Hash)
end

#oauth_token_secret=(secret) ⇒ Object



49
50
51
# File 'lib/rest-core/client_oauth1.rb', line 49

def oauth_token_secret= secret
  data['oauth_token_secret'] = secret if data.kind_of?(Hash)
end