singly 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/singly.rb +5 -1
- data/lib/singly/account.rb +4 -4
- data/lib/singly/api/profiles.rb +5 -2
- data/lib/singly/api/profiles/service.rb +6 -3
- data/lib/singly/api/services.rb +4 -2
- data/lib/singly/api/services/37signals.rb +0 -1
- data/lib/singly/api/services/bodymedia.rb +1 -2
- data/lib/singly/api/services/dropbox.rb +1 -2
- data/lib/singly/api/services/dwolla.rb +1 -2
- data/lib/singly/api/services/endpoint.rb +1 -1
- data/lib/singly/api/services/facebook.rb +1 -2
- data/lib/singly/api/services/fitbit.rb +1 -2
- data/lib/singly/api/services/flickr.rb +1 -4
- data/lib/singly/api/services/foursquare.rb +1 -2
- data/lib/singly/api/services/gcal.rb +1 -2
- data/lib/singly/api/services/gcontacts.rb +1 -2
- data/lib/singly/api/services/gdocs.rb +1 -2
- data/lib/singly/api/services/github.rb +1 -2
- data/lib/singly/api/services/gmail.rb +1 -2
- data/lib/singly/api/services/google.rb +1 -2
- data/lib/singly/api/services/gplus.rb +1 -2
- data/lib/singly/api/services/imgur.rb +1 -2
- data/lib/singly/api/services/instagram.rb +1 -2
- data/lib/singly/api/services/klout.rb +1 -2
- data/lib/singly/api/services/linkedin.rb +1 -2
- data/lib/singly/api/services/meetup.rb +1 -2
- data/lib/singly/api/services/paypal.rb +1 -2
- data/lib/singly/api/services/picasa.rb +1 -2
- data/lib/singly/api/services/rdio.rb +1 -2
- data/lib/singly/api/services/reddit.rb +1 -2
- data/lib/singly/api/services/runkeeper.rb +1 -2
- data/lib/singly/api/services/service.rb +9 -31
- data/lib/singly/api/services/shutterfly.rb +1 -2
- data/lib/singly/api/services/soundcloud.rb +1 -2
- data/lib/singly/api/services/stocktwits.rb +1 -2
- data/lib/singly/api/services/tout.rb +1 -2
- data/lib/singly/api/services/tumblr.rb +1 -2
- data/lib/singly/api/services/twitter.rb +1 -2
- data/lib/singly/api/services/withings.rb +1 -2
- data/lib/singly/api/services/wordpress.rb +1 -2
- data/lib/singly/api/services/yammer.rb +1 -2
- data/lib/singly/api/services/youtube.rb +1 -2
- data/lib/singly/api/services/zeo.rb +1 -2
- data/lib/singly/endpoint.rb +52 -43
- data/lib/singly/error.rb +6 -4
- data/lib/singly/http.rb +7 -8
- data/lib/version.rb +1 -1
- data/spec/integration/account/apply_spec.rb +36 -0
- data/spec/integration/account/delete_spec.rb +23 -0
- data/spec/integration/account/friends_spec.rb +51 -0
- data/spec/integration/account/id_spec.rb +23 -0
- data/spec/integration/account/merge_spec.rb +14 -0
- data/spec/integration/account/profile_spec.rb +14 -0
- data/spec/integration/account/profiles_spec.rb +64 -0
- data/spec/integration/account/proxy_spec.rb +43 -0
- data/spec/integration/account/services_spec.rb +62 -0
- data/spec/integration/account/types_spec.rb +57 -0
- data/spec/integration/api_spec.rb +77 -0
- data/spec/singly/account_spec.rb +8 -8
- data/spec/singly/endpoint_spec.rb +53 -45
- data/spec/singly/error_spec.rb +21 -13
- data/spec/singly/http_spec.rb +26 -13
- data/spec/singly_spec.rb +1 -1
- data/spec/spec_helper.rb +6 -0
- data/spec/vcr_cassettes/{http_fetch_with_api_error.yml → singly/http_fetch_with_api_error.yml} +3 -3
- data/spec/vcr_cassettes/{http_fetch_with_json_response.yml → singly/http_fetch_with_json_response.yml} +2 -2
- data/spec/vcr_cassettes/{http_fetch_with_non_json_response.yml → singly/http_fetch_with_non_json_response.yml} +2 -2
- metadata +30 -12
- data/spec/integration/auth_spec.rb +0 -14
- data/spec/singly/api/auth_spec.rb +0 -8
data/lib/singly.rb
CHANGED
@@ -13,7 +13,7 @@ Dir["#{File.dirname(__FILE__)}/**/*.rb"].each {|f| require(f)}
|
|
13
13
|
|
14
14
|
module Singly
|
15
15
|
@version = "v0"
|
16
|
-
@timeout =
|
16
|
+
@timeout = 2 # Typheous timeouts are in seconds, not like the docs say
|
17
17
|
|
18
18
|
class << self
|
19
19
|
attr_accessor :client_id
|
@@ -22,6 +22,10 @@ module Singly
|
|
22
22
|
attr_accessor :version
|
23
23
|
attr_accessor :timeout
|
24
24
|
|
25
|
+
def services
|
26
|
+
Singly::Services.new
|
27
|
+
end
|
28
|
+
|
25
29
|
def account(access_token, account=nil)
|
26
30
|
Singly::Account.new(access_token, account)
|
27
31
|
end
|
data/lib/singly/account.rb
CHANGED
@@ -42,7 +42,9 @@ module Singly
|
|
42
42
|
# Alternative to calling #profiles.<service>.delete.
|
43
43
|
# Useful if you don't know the exact service at runtime.
|
44
44
|
def delete(service, id=nil)
|
45
|
-
Singly::Profiles::Service.new(access_token: access_token
|
45
|
+
endpoint = Singly::Profiles::Service.new(access_token: access_token)
|
46
|
+
endpoint.service = service
|
47
|
+
endpoint.delete(id)
|
46
48
|
end
|
47
49
|
|
48
50
|
# Shortcut to Singly.auth.merge(source: <source>, dest: <dest>)
|
@@ -55,9 +57,7 @@ module Singly
|
|
55
57
|
# where <account_id> is always this account's account_id.
|
56
58
|
# If the account_id is not present, it is fetched from the api.
|
57
59
|
def apply(service, params)
|
58
|
-
|
59
|
-
service = Singly::Auth::Service.new(service, is_oauth1)
|
60
|
-
service.apply(params.merge(account: account_id))
|
60
|
+
Singly.auth.send(service).apply(params.merge(account: account_id))
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
data/lib/singly/api/profiles.rb
CHANGED
@@ -15,7 +15,8 @@ module Singly
|
|
15
15
|
# required parameters, it sends a GET.
|
16
16
|
# Otherwise it sends a POST.
|
17
17
|
def self(params=nil)
|
18
|
-
|
18
|
+
params ||= {}
|
19
|
+
if (params.keys - self.class.required_params).empty?
|
19
20
|
Singly::Profiles::Self.new(creds)
|
20
21
|
else
|
21
22
|
Singly::Profiles::SelfUpdate.new(creds.merge(params))
|
@@ -172,7 +173,9 @@ module Singly
|
|
172
173
|
|
173
174
|
def service(service, params)
|
174
175
|
params ||= {}
|
175
|
-
Singly::Profiles::Service.new(creds.merge(params.merge(service: service.to_s)))
|
176
|
+
endpoint = Singly::Profiles::Service.new(creds.merge(params.merge(service: service.to_s)))
|
177
|
+
endpoint.service = service.to_s
|
178
|
+
endpoint
|
176
179
|
end
|
177
180
|
end
|
178
181
|
end
|
@@ -6,13 +6,16 @@ module Singly
|
|
6
6
|
endpoint :get, "/profiles/:service", required: [:access_token], optional: [:auth]
|
7
7
|
|
8
8
|
def delete(id=nil)
|
9
|
-
service = route_params[:service]
|
10
9
|
if id
|
11
|
-
Singly::Profiles::DeleteProfile.new(creds.merge({service: service, id: id.to_s}))
|
10
|
+
Singly::Profiles::DeleteProfile.new(creds.merge({service: @service, id: id.to_s}))
|
12
11
|
else
|
13
|
-
Singly::Profiles::DeleteService.new(creds.merge({service: service}))
|
12
|
+
Singly::Profiles::DeleteService.new(creds.merge({service: @service}))
|
14
13
|
end
|
15
14
|
end
|
15
|
+
|
16
|
+
def service=(service)
|
17
|
+
@service = service
|
18
|
+
end
|
16
19
|
end
|
17
20
|
end
|
18
21
|
end
|
data/lib/singly/api/services.rb
CHANGED
@@ -2,7 +2,7 @@ module Singly
|
|
2
2
|
class Services
|
3
3
|
include Singly::Endpoint
|
4
4
|
|
5
|
-
endpoint :get, "/services"
|
5
|
+
endpoint :get, "/services"
|
6
6
|
|
7
7
|
def thirtysevensignals(params={})
|
8
8
|
service(Singly::Services::ThirtySevenSignals, "37signals", params)
|
@@ -152,7 +152,9 @@ module Singly
|
|
152
152
|
|
153
153
|
def service(endpoint_type, service, params)
|
154
154
|
params ||= {}
|
155
|
-
endpoint_type.new(creds.merge(params.merge(service: service.to_s)))
|
155
|
+
endpoint = endpoint_type.new(creds.merge(params.merge(service: service.to_s)))
|
156
|
+
endpoint.service = service.to_s
|
157
|
+
endpoint
|
156
158
|
end
|
157
159
|
end
|
158
160
|
end
|
@@ -5,7 +5,7 @@ module Singly
|
|
5
5
|
|
6
6
|
endpoint :get, "/services/:service/:endpoint", {
|
7
7
|
required: [:access_token],
|
8
|
-
optional: [:
|
8
|
+
optional: [:fields, :limit, :since, :until, :near, :within, :q, :participants, :map]
|
9
9
|
}
|
10
10
|
end
|
11
11
|
end
|
@@ -2,46 +2,24 @@ module Singly
|
|
2
2
|
class Services
|
3
3
|
module Service
|
4
4
|
|
5
|
-
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
include Singly::Endpoint
|
8
|
+
endpoint :get, "/services/:service", required: [:access_token]
|
9
|
+
end
|
10
|
+
end
|
6
11
|
|
7
12
|
def service_endpoint(endpoint_name, params)
|
8
13
|
params ||= {}
|
9
14
|
endpoint_type = params.has_key?(:id) ? Singly::Services::IdEndpoint : Singly::Services::Endpoint
|
10
15
|
endpoint_type.new(creds.merge(params.merge({
|
11
|
-
service:
|
16
|
+
service: @service,
|
12
17
|
endpoint: endpoint_name.to_s
|
13
18
|
})))
|
14
19
|
end
|
15
20
|
|
16
|
-
def
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
# service :facebook, [:albums, :photos]
|
21
|
-
module ClassMethods
|
22
|
-
def type
|
23
|
-
:get
|
24
|
-
end
|
25
|
-
|
26
|
-
def path
|
27
|
-
"/services/:service"
|
28
|
-
end
|
29
|
-
|
30
|
-
def required_params
|
31
|
-
[:access_token]
|
32
|
-
end
|
33
|
-
|
34
|
-
def optional_params
|
35
|
-
[]
|
36
|
-
end
|
37
|
-
|
38
|
-
def service_name
|
39
|
-
@service || ":service"
|
40
|
-
end
|
41
|
-
|
42
|
-
def service(service)
|
43
|
-
@service = service
|
44
|
-
end
|
21
|
+
def service=(service)
|
22
|
+
@service = service
|
45
23
|
end
|
46
24
|
end
|
47
25
|
end
|