sparkmotion 0.0.1.1 → 0.0.1.2
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/sparkmotion/sparkmotion.rb +16 -18
- data/lib/sparkmotion/version.rb +2 -2
- metadata +1 -1
@@ -43,8 +43,8 @@ module SparkMotion
|
|
43
43
|
attr_accessor *DEBUGGER
|
44
44
|
|
45
45
|
DEFAULT = {
|
46
|
-
api_key:
|
47
|
-
api_secret:
|
46
|
+
api_key: "YourAPIKey",
|
47
|
+
api_secret: "YourAPISecret",
|
48
48
|
api_user: nil,
|
49
49
|
callback: "https://sparkplatform.com/oauth2/callback",
|
50
50
|
endpoint: "https://developers.sparkapi.com", # change to https://api.developers.sparkapi.com for production
|
@@ -66,15 +66,15 @@ module SparkMotion
|
|
66
66
|
puts "#{self} initializing..."
|
67
67
|
@@instances << self
|
68
68
|
(VALID_OPTION_KEYS + ACCESS_KEYS).each do |key|
|
69
|
-
send("#{key.to_s}=", DEFAULT[key])
|
69
|
+
send("#{key.to_s}=", opts[key] || DEFAULT[key])
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
# Sample Usage:
|
74
74
|
# client = SparkMotion::OAuth2Client.new
|
75
75
|
# client.configure do |config|
|
76
|
-
# config.api_key = "
|
77
|
-
# config.api_secret = "
|
76
|
+
# config.api_key = "YourAPIKey"
|
77
|
+
# config.api_secret = "YourAPISecret"
|
78
78
|
# config.callback = "https://sparkplatform.com/oauth2/callback"
|
79
79
|
# config.auth_endpoint = "https://sparkplatform.com/oauth2"
|
80
80
|
# config.endpoint = 'https://developers.sparkapi.com'
|
@@ -99,7 +99,7 @@ module SparkMotion
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
return
|
102
|
+
return
|
103
103
|
end
|
104
104
|
|
105
105
|
def authorize &block
|
@@ -137,21 +137,20 @@ module SparkMotion
|
|
137
137
|
# https://<spark_endpoint>/<api version>/<spark resource>
|
138
138
|
complete_url = self.endpoint + "/#{version}" + spark_url
|
139
139
|
|
140
|
-
headers = {
|
141
|
-
:"User-Agent" => "MotionSpark RubyMotion Sample App",
|
142
|
-
:"X-SparkApi-User-Agent" => "MotionSpark RubyMotion Sample App",
|
143
|
-
:"Authorization" => "OAuth #{self.access_token}"
|
144
|
-
}
|
145
|
-
|
146
|
-
opts={}
|
147
|
-
opts.merge!(options)
|
148
|
-
opts.merge!({:headers => headers})
|
149
|
-
|
150
140
|
block ||= lambda { |returned|
|
151
141
|
puts("SparkMotion: default callback")
|
152
142
|
}
|
153
143
|
|
154
144
|
request = lambda {
|
145
|
+
# refresh Authorization header every time `request` is called
|
146
|
+
headers = {
|
147
|
+
:"User-Agent" => "MotionSpark RubyMotion Sample App",
|
148
|
+
:"X-SparkApi-User-Agent" => "MotionSpark RubyMotion Sample App",
|
149
|
+
:"Authorization" => "OAuth #{self.access_token}"
|
150
|
+
}
|
151
|
+
opts={:headers => headers}
|
152
|
+
opts.merge!(options)
|
153
|
+
|
155
154
|
BW::HTTP.get(complete_url, opts) do |response|
|
156
155
|
puts "SparkMotion: [status code #{response.status_code}] [#{spark_url}]"
|
157
156
|
|
@@ -193,8 +192,7 @@ module SparkMotion
|
|
193
192
|
end
|
194
193
|
|
195
194
|
def authorized?
|
196
|
-
|
197
|
-
self.refresh_token && self.authorized ? true : false
|
195
|
+
self.refresh_token && self.authorized
|
198
196
|
end
|
199
197
|
|
200
198
|
private
|
data/lib/sparkmotion/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module SparkMotion
|
2
|
-
VERSION = "0.0.1.
|
3
|
-
end
|
2
|
+
VERSION = "0.0.1.2"
|
3
|
+
end
|