kynetx_am_api 0.1.12 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/kynetx_am_api/application.rb +4 -1
- data/lib/kynetx_am_api/direct_api.rb +4 -4
- data/lib/kynetx_am_api/oauth.rb +20 -11
- data/lib/kynetx_am_api/user.rb +13 -0
- metadata +2 -2
@@ -158,7 +158,7 @@ module KynetxAmApi
|
|
158
158
|
options = {
|
159
159
|
"extname" => name,
|
160
160
|
"extdesc" => description,
|
161
|
-
"extauthor" => author.
|
161
|
+
"extauthor" => author.to_s.empty? ? @user.name : author
|
162
162
|
}
|
163
163
|
options["appguid"] = @guid if type == :ie
|
164
164
|
return @api.post_app_generate(@application_id, type.to_s, options)
|
@@ -175,6 +175,9 @@ module KynetxAmApi
|
|
175
175
|
def load_base
|
176
176
|
app_details = @api.get_app_details(@application_id)
|
177
177
|
puts "APPDETAILS: #{app_details.inspect}" if $DEBUG
|
178
|
+
if app_details["error"]
|
179
|
+
raise app_details["error"]
|
180
|
+
end
|
178
181
|
@name = app_details["name"]
|
179
182
|
@application_id = app_details["appid"]
|
180
183
|
@guid = app_details["guid"]
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module KynetxAmApi
|
2
|
+
require 'rubygems'
|
2
3
|
require 'oauth'
|
3
4
|
require 'json'
|
4
|
-
require 'pp'
|
5
5
|
require 'net/http/post/multipart'
|
6
6
|
|
7
7
|
class DirectApi
|
@@ -149,7 +149,7 @@ module KynetxAmApi
|
|
149
149
|
|
150
150
|
def get_user_info
|
151
151
|
user = @oauth.user
|
152
|
-
if user.username.
|
152
|
+
if user.username.to_s.empty?
|
153
153
|
user_info = get_response("userinfo", :json)
|
154
154
|
user.username = user_info["username"]
|
155
155
|
user.userid = user_info["userid"]
|
@@ -192,10 +192,10 @@ module KynetxAmApi
|
|
192
192
|
puts "---------POST--------------" if $DEBUG
|
193
193
|
puts api_call if $DEBUG
|
194
194
|
puts data.inspect if $DEBUG
|
195
|
-
puts "___________________________"
|
195
|
+
puts "___________________________" if $DEBUG
|
196
196
|
response = @oauth.get_access_token.post(api_call, data, headers).body
|
197
197
|
puts response.inspect if $DEBUG
|
198
|
-
puts "---------------------------"
|
198
|
+
puts "---------------------------" if $DEBUG
|
199
199
|
begin
|
200
200
|
response = JSON.parse(response) if format == :json
|
201
201
|
rescue
|
data/lib/kynetx_am_api/oauth.rb
CHANGED
@@ -3,10 +3,6 @@ module KynetxAmApi
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
class Oauth
|
6
|
-
cattr_accessor :accounts_server_url
|
7
|
-
cattr_accessor :api_server_url
|
8
|
-
cattr_accessor :consumer_key
|
9
|
-
cattr_accessor :consumer_secret
|
10
6
|
|
11
7
|
attr_accessor :request_token
|
12
8
|
attr_accessor :account_consumer
|
@@ -33,6 +29,22 @@ module KynetxAmApi
|
|
33
29
|
end
|
34
30
|
|
35
31
|
|
32
|
+
def self.accounts_server_url=(v)
|
33
|
+
@@accounts_server_url = v
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.api_server_url=(v)
|
37
|
+
@@api_server_url = v
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.consumer_key=(v)
|
41
|
+
@@consumer_key = v
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.consumer_secret=(v)
|
45
|
+
@@consumer_secret = v
|
46
|
+
end
|
47
|
+
|
36
48
|
private
|
37
49
|
|
38
50
|
|
@@ -44,13 +56,10 @@ module KynetxAmApi
|
|
44
56
|
|
45
57
|
end
|
46
58
|
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
59
|
def get_account_consumer
|
51
60
|
return @account_consumer if @account_consumer
|
52
|
-
return @account_consumer = OAuth::Consumer.new(
|
53
|
-
:site =>
|
61
|
+
return @account_consumer = OAuth::Consumer.new(@@consumer_key, @@consumer_secret, {
|
62
|
+
:site => @@accounts_server_url,
|
54
63
|
:scheme => :header,
|
55
64
|
:method => :get,
|
56
65
|
:request_token_path => "/oauth/request_token",
|
@@ -65,8 +74,8 @@ module KynetxAmApi
|
|
65
74
|
|
66
75
|
def get_api_consumer
|
67
76
|
return @api_consumer if @api_consumer
|
68
|
-
return @api_consumer = OAuth::Consumer.new(
|
69
|
-
:site =>
|
77
|
+
return @api_consumer = OAuth::Consumer.new(@@consumer_key, @@consumer_secret, {
|
78
|
+
:site => @@api_server_url,
|
70
79
|
:scheme => :header,
|
71
80
|
:method => :get,
|
72
81
|
:request_token_path => "/oauth/request_token",
|
data/lib/kynetx_am_api/user.rb
CHANGED
@@ -106,6 +106,19 @@ module KynetxAmApi
|
|
106
106
|
return false unless @current_application
|
107
107
|
return @current_application.owner["kynetxuserid"].to_i == self.userid.to_i
|
108
108
|
end
|
109
|
+
|
110
|
+
def to_h
|
111
|
+
return {
|
112
|
+
:access_secret => @access_secret,
|
113
|
+
:access_token => @access_token,
|
114
|
+
:request_token => @request_token,
|
115
|
+
:request_secret => @request_secret,
|
116
|
+
:oauth_verifier => @oauth_verifier,
|
117
|
+
:name => @name,
|
118
|
+
:userid => @userid,
|
119
|
+
:username => @username
|
120
|
+
}
|
121
|
+
end
|
109
122
|
|
110
123
|
|
111
124
|
end
|