appoxy_rails 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/appoxy_api.rb +1 -3
- metadata +14 -16
- data/lib/api/client.rb +0 -117
- data/lib/api/client_helper.rb +0 -32
data/lib/appoxy_api.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appoxy_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-02-
|
12
|
+
date: 2011-02-19 00:00:00.000000000 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
17
|
-
requirement: &
|
17
|
+
requirement: &27547968 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *27547968
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: oauth
|
28
|
-
requirement: &
|
28
|
+
requirement: &27547644 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *27547644
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: ruby-openid
|
39
|
-
requirement: &
|
39
|
+
requirement: &27547320 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *27547320
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: appoxy_api
|
50
|
-
requirement: &
|
50
|
+
requirement: &27546996 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *27546996
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: mini_fb
|
61
|
-
requirement: &
|
61
|
+
requirement: &27546660 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *27546660
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: simple_record
|
72
|
-
requirement: &
|
72
|
+
requirement: &27546348 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,7 +77,7 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *27546348
|
81
81
|
description: Appoxy API Helper gem description...
|
82
82
|
email: travis@appoxy.com
|
83
83
|
executables: []
|
@@ -86,8 +86,6 @@ extra_rdoc_files:
|
|
86
86
|
- README.markdown
|
87
87
|
files:
|
88
88
|
- lib/api/api_controller.rb
|
89
|
-
- lib/api/client.rb
|
90
|
-
- lib/api/client_helper.rb
|
91
89
|
- lib/api/signatures.rb
|
92
90
|
- lib/appoxy_api.rb
|
93
91
|
- lib/appoxy_rails.rb
|
data/lib/api/client.rb
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
module Appoxy
|
2
|
-
module Api
|
3
|
-
|
4
|
-
require 'rest_client'
|
5
|
-
|
6
|
-
# Subclass must define:
|
7
|
-
# host: endpoint url for service
|
8
|
-
class Client
|
9
|
-
|
10
|
-
attr_accessor :host, :access_key, :secret_key, :version
|
11
|
-
|
12
|
-
|
13
|
-
def initialize(host, access_key, secret_key, options={})
|
14
|
-
@host = host
|
15
|
-
@access_key = access_key
|
16
|
-
@secret_key = secret_key
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
def get(method, params={}, options={})
|
21
|
-
begin
|
22
|
-
# ClientHelper.run_http(host, access_key, secret_key, :get, method, nil, params)
|
23
|
-
parse_response RestClient.get(append_params(url(method), add_params(method, params)), headers)
|
24
|
-
rescue RestClient::BadRequest => ex
|
25
|
-
# puts ex.http_body
|
26
|
-
raise "Bad Request: " + ActiveSupport::JSON.decode(ex.http_body)["msg"].to_s
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
def post(method, params={}, options={})
|
32
|
-
begin
|
33
|
-
parse_response RestClient.post(url(method), add_params(method, params).to_json, headers)
|
34
|
-
#ClientHelper.run_http(host, access_key, secret_key, :post, method, nil, params)
|
35
|
-
rescue RestClient::BadRequest => ex
|
36
|
-
# puts ex.http_body
|
37
|
-
raise "Bad Request: " + ActiveSupport::JSON.decode(ex.http_body)["msg"].to_s
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
def put(method, body, options={})
|
44
|
-
begin
|
45
|
-
parse_response RestClient.put(url(method), add_params(method, body).to_json, headers)
|
46
|
-
#ClientHelper.run_http(host, access_key, secret_key, :put, method, body, nil)
|
47
|
-
rescue RestClient::BadRequest => ex
|
48
|
-
# puts ex.http_body
|
49
|
-
raise "Bad Request: " + ActiveSupport::JSON.decode(ex.http_body)["msg"].to_s
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
def delete(method, params={}, options={})
|
55
|
-
begin
|
56
|
-
parse_response RestClient.delete(append_params(url(method), add_params(method, params)))
|
57
|
-
rescue RestClient::BadRequest => ex
|
58
|
-
raise "Bad Request: " + ActiveSupport::JSON.decode(ex.http_body)["msg"].to_s
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
def url(command_path)
|
64
|
-
url = host + command_path
|
65
|
-
url
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
def add_params(command_path, hash)
|
70
|
-
v = version||"0.1"
|
71
|
-
ts = Appoxy::Api::Signatures.generate_timestamp(Time.now.gmtime)
|
72
|
-
# puts 'timestamp = ' + ts
|
73
|
-
sig = case v
|
74
|
-
when "0.2"
|
75
|
-
Appoxy::Api::Signatures.generate_signature(command_path + Appoxy::Api::Signatures.hash_to_s(hash), ts, secret_key)
|
76
|
-
when "0.1"
|
77
|
-
Appoxy::Api::Signatures.generate_signature(command_path, ts, secret_key)
|
78
|
-
end
|
79
|
-
|
80
|
-
extra_params = {'sigv'=>v, 'sig' => sig, 'timestamp' => ts, 'access_key' => access_key}
|
81
|
-
hash.merge!(extra_params)
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
def append_params(host, params)
|
87
|
-
host += "?"
|
88
|
-
i = 0
|
89
|
-
params.each_pair do |k, v|
|
90
|
-
host += "&" if i > 0
|
91
|
-
host += k + "=" + CGI.escape(v)
|
92
|
-
i+=1
|
93
|
-
end
|
94
|
-
return host
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
def headers
|
99
|
-
user_agent = "Appoxy API Ruby Client"
|
100
|
-
headers = {'User-Agent' => user_agent}
|
101
|
-
end
|
102
|
-
|
103
|
-
|
104
|
-
def parse_response(response)
|
105
|
-
begin
|
106
|
-
return ActiveSupport::JSON.decode(response.to_s)
|
107
|
-
rescue => ex
|
108
|
-
puts 'response that caused error = ' + response.to_s
|
109
|
-
raise ex
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|
117
|
-
end
|
data/lib/api/client_helper.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
module Appoxy
|
2
|
-
module Api
|
3
|
-
|
4
|
-
require 'rest_client'
|
5
|
-
|
6
|
-
module ClientHelper
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
class ClientError < StandardError
|
12
|
-
|
13
|
-
attr_reader :response_hash
|
14
|
-
|
15
|
-
def initialize(class_name, response_hash)
|
16
|
-
puts 'response-hash=' + response_hash.inspect
|
17
|
-
super("#{class_name} - #{response_hash["msg"]}")
|
18
|
-
@response_hash = response_hash
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class ServiceError < StandardError
|
23
|
-
attr_reader :body
|
24
|
-
|
25
|
-
def initialize(class_name, body)
|
26
|
-
super("#{class_name}")
|
27
|
-
@body = body
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|