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

- (Object) authorize!(opts = {})



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

- (Object) authorize_url



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

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

- (Object) authorize_url!(opts = {})



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

- (Boolean) authorized?



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

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

- (Object) data_json



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

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

- (Object) data_json=(json)



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

- (Object) oauth_callback



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

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

- (Object) oauth_callback=(uri)



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

- (Object) oauth_token



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

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

- (Object) oauth_token=(token)



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

- (Object) oauth_token_secret



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

- (Object) oauth_token_secret=(secret)



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