social_net 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +94 -0
- data/MIT-LICENSE +20 -0
- data/README.md +264 -0
- data/Rakefile +2 -0
- data/coverage/.last_run.json +5 -0
- data/coverage/.resultset.json +847 -0
- data/coverage/.resultset.json.lock +0 -0
- data/coverage/assets/0.9.0/application.css +799 -0
- data/coverage/assets/0.9.0/application.js +1707 -0
- data/coverage/assets/0.9.0/colorbox/border.png +0 -0
- data/coverage/assets/0.9.0/colorbox/controls.png +0 -0
- data/coverage/assets/0.9.0/colorbox/loading.gif +0 -0
- data/coverage/assets/0.9.0/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.9.0/favicon_green.png +0 -0
- data/coverage/assets/0.9.0/favicon_red.png +0 -0
- data/coverage/assets/0.9.0/favicon_yellow.png +0 -0
- data/coverage/assets/0.9.0/loading.gif +0 -0
- data/coverage/assets/0.9.0/magnify.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.9.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/index.html +5624 -0
- data/lib/social_net/facebook/api/configuration.rb +14 -0
- data/lib/social_net/facebook/api/request.rb +66 -0
- data/lib/social_net/facebook/config.rb +16 -0
- data/lib/social_net/facebook/errors/response_error.rb +14 -0
- data/lib/social_net/facebook/errors/unknown_user.rb +11 -0
- data/lib/social_net/facebook/errors.rb +2 -0
- data/lib/social_net/facebook/models/page.rb +49 -0
- data/lib/social_net/facebook/models/user.rb +66 -0
- data/lib/social_net/facebook/models.rb +2 -0
- data/lib/social_net/facebook.rb +11 -0
- data/lib/social_net/instagram/api/configuration.rb +13 -0
- data/lib/social_net/instagram/api/request.rb +63 -0
- data/lib/social_net/instagram/config.rb +16 -0
- data/lib/social_net/instagram/errors/response_error.rb +14 -0
- data/lib/social_net/instagram/errors/unknown_user.rb +11 -0
- data/lib/social_net/instagram/errors.rb +2 -0
- data/lib/social_net/instagram/models/user.rb +70 -0
- data/lib/social_net/instagram/models.rb +1 -0
- data/lib/social_net/instagram.rb +10 -0
- data/lib/social_net/twitter/api/configuration.rb +16 -0
- data/lib/social_net/twitter/api/request.rb +121 -0
- data/lib/social_net/twitter/config.rb +15 -0
- data/lib/social_net/twitter/errors/response_error.rb +14 -0
- data/lib/social_net/twitter/errors/suspended_user.rb +11 -0
- data/lib/social_net/twitter/errors/too_many_users.rb +11 -0
- data/lib/social_net/twitter/errors/unknown_user.rb +11 -0
- data/lib/social_net/twitter/errors.rb +4 -0
- data/lib/social_net/twitter/models/user.rb +81 -0
- data/lib/social_net/twitter/models.rb +1 -0
- data/lib/social_net/twitter.rb +11 -0
- data/lib/social_net/version.rb +3 -0
- data/lib/social_net.rb +7 -0
- data/social_net-0.1.0.gem +0 -0
- data/social_net.gemspec +30 -0
- data/spec/social_net/facebook/models/pages_spec.rb +42 -0
- data/spec/social_net/facebook/models/users_spec.rb +44 -0
- data/spec/social_net/instagram/models/user_spec.rb +50 -0
- data/spec/social_net/twitter/models/user_spec.rb +98 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/cassettes/SocialNet_Instagram_Models_User/_find_by/given_an_existing_case-insensitive_username/returns_an_object_representing_that_user.yml +106 -0
- data/spec/support/cassettes/SocialNet_Instagram_Models_User/_find_by/given_an_unknown_username/.yml +51 -0
- data/spec/support/cassettes/SocialNet_Instagram_Models_User/_find_by_/given_an_existing_case-insensitive_username/returns_an_object_representing_that_user.yml +106 -0
- data/spec/support/cassettes/SocialNet_Instagram_Models_User/_find_by_/given_an_unknown_username/.yml +51 -0
- data/spec/support/vcr.rb +22 -0
- metadata +245 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'social_net/twitter/api/request'
|
2
|
+
require 'social_net/twitter/errors'
|
3
|
+
|
4
|
+
module SocialNet
|
5
|
+
module Twitter
|
6
|
+
module Models
|
7
|
+
class User
|
8
|
+
attr_reader :screen_name, :follower_count
|
9
|
+
|
10
|
+
def initialize(attrs = {})
|
11
|
+
attrs.each{|k, v| instance_variable_set("@#{k}", v) unless v.nil?}
|
12
|
+
@follower_count = attrs['followers_count']
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns the existing Twitter user matching the provided attributes or
|
16
|
+
# nil when the user is not found.
|
17
|
+
#
|
18
|
+
# @return [SocialNet::Twitter::Models::User] when the user is found.
|
19
|
+
# @return [nil] when the user is not found or suspended.
|
20
|
+
# @param [Hash] params the attributes to find a user by.
|
21
|
+
# @option params [String] :screen_name The Twitter user’s screen name
|
22
|
+
# (case-insensitive).
|
23
|
+
def self.find_by(params = {})
|
24
|
+
find_by! params
|
25
|
+
rescue Errors::UnknownUser, Errors::SuspendedUser
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns the existing Twitter user matching the provided attributes or
|
30
|
+
# raises an error when the user is not found or suspended.
|
31
|
+
#
|
32
|
+
# @return [SocialNet::Twitter::Models::User] the Twitter user.
|
33
|
+
# @param [Hash] params the attributes to find a user by.
|
34
|
+
# @option params [String] :screen_name The Twitter user’s screen name
|
35
|
+
# (case-insensitive).
|
36
|
+
# @raise [SocialNet::Errors::UnknownUser] if the user cannot be found.
|
37
|
+
# @raise [SocialNet::Errors::SuspendedUser] if the user account is suspended.
|
38
|
+
def self.find_by!(params = {})
|
39
|
+
request = Api::Request.new endpoint: 'users/show', params: params
|
40
|
+
user_data = request.run
|
41
|
+
new user_data
|
42
|
+
rescue Errors::ResponseError => error
|
43
|
+
case error.response
|
44
|
+
when Net::HTTPNotFound then raise Errors::UnknownUser
|
45
|
+
when Net::HTTPForbidden then raise Errors::SuspendedUser
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns up to 100 existing Twitter users matching the provided
|
50
|
+
# attributes. Raises an error when requesting more than 100 users.
|
51
|
+
# Does not return users in the same order that they are requested.
|
52
|
+
|
53
|
+
# @return [Array<SocialNet::Twitter::Models::User>] the Twitter users.
|
54
|
+
# @param [Hash] conditions The attributes to find users by.
|
55
|
+
# @option conditions [Array<String>] screen_name The Twitter user's
|
56
|
+
# screen names (case-insensitive).
|
57
|
+
# @raise [SocialNet::Errors::TooManyUsers] when more than 100 Twitter users
|
58
|
+
# match the provided attributes.
|
59
|
+
def self.where(conditions = {})
|
60
|
+
params = to_where_params conditions
|
61
|
+
request = Api::Request.new endpoint: 'users/lookup', params: params
|
62
|
+
users_data = request.run
|
63
|
+
users_data.map{|user_data| new user_data}
|
64
|
+
rescue Errors::ResponseError => error
|
65
|
+
case error.response
|
66
|
+
when Net::HTTPNotFound then []
|
67
|
+
when Net::HTTPForbidden then raise Errors::TooManyUsers
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def self.to_where_params(conditions = {})
|
74
|
+
conditions.dup.tap do |params|
|
75
|
+
params.each{|k,v| params[k] = v.join(',') if v.is_a?(Array)}
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'social_net/twitter/models/user'
|
data/lib/social_net.rb
ADDED
Binary file
|
data/social_net.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'social_net/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "social_net"
|
8
|
+
spec.version = SocialNet::VERSION
|
9
|
+
spec.authors = ["Jeremy Cohen Hoffing"]
|
10
|
+
spec.email = ["jeremy@collabcreators.com"]
|
11
|
+
spec.summary = %q{An API Client for social networks}
|
12
|
+
spec.description = %q{Retrieves information for Instagram users}
|
13
|
+
spec.homepage = "https://github.com/CollabCreators/social_net"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'activesupport'
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.3"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
26
|
+
spec.add_development_dependency "yard", "~> 0.8.7"
|
27
|
+
spec.add_development_dependency "coveralls", "~> 0.7.1"
|
28
|
+
spec.add_development_dependency "vcr", "~> 2.9"
|
29
|
+
spec.add_development_dependency "webmock", "~> 1.19"
|
30
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SocialNet::Facebook::Page do
|
4
|
+
let(:unknown_username) { 'qeqwe09qlkmhkjh' }
|
5
|
+
let(:existing_username) { 'collab' }
|
6
|
+
|
7
|
+
describe '.find_by' do
|
8
|
+
subject(:page) { SocialNet::Facebook::Page.find_by username: username }
|
9
|
+
|
10
|
+
context 'given an existing (case-insensitive) username' do
|
11
|
+
let (:username) { existing_username }
|
12
|
+
|
13
|
+
it 'returns an object representing the page for that user' do
|
14
|
+
expect(page.username).to eq 'collab'
|
15
|
+
expect(page.likes).to be_an Integer
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'given an unknown username' do
|
20
|
+
let(:username) { unknown_username }
|
21
|
+
it { expect(page).to be_nil }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.find_by!' do
|
26
|
+
subject(:page) { SocialNet::Facebook::Page.find_by! username: username }
|
27
|
+
|
28
|
+
context 'given an existing (case-insensitive) username' do
|
29
|
+
let(:username) { existing_username }
|
30
|
+
|
31
|
+
it 'returns an object representing the page for that user' do
|
32
|
+
expect(page.username).to eq 'collab'
|
33
|
+
expect(page.likes).to be_an Integer
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'given an unknown username' do
|
38
|
+
let(:username) { unknown_username }
|
39
|
+
it { expect{page}.to raise_error SocialNet::Facebook::UnknownUser }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SocialNet::Facebook::User do
|
4
|
+
let(:unknown_username) { 'qeqwe09qlkmhkjh' }
|
5
|
+
let(:existing_username) { '1453280268327112' }
|
6
|
+
|
7
|
+
describe '.find_by' do
|
8
|
+
subject(:user) { SocialNet::Facebook::User.find_by username: username }
|
9
|
+
|
10
|
+
context 'given an existing (case-insensitive) username' do
|
11
|
+
let (:username) { existing_username }
|
12
|
+
|
13
|
+
it 'returns an object representing the user' do
|
14
|
+
expect(user.first_name).to eq 'Jeremy'
|
15
|
+
expect(user.last_name).to eq 'Dev'
|
16
|
+
expect(user.gender).to eq 'male'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'given an unknown username' do
|
21
|
+
let(:username) { unknown_username }
|
22
|
+
it { expect(user).to be_nil }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '.find_by!' do
|
27
|
+
subject(:user) { SocialNet::Facebook::User.find_by! username: username }
|
28
|
+
|
29
|
+
context 'given an existing (case-insensitive) username' do
|
30
|
+
let(:username) { existing_username }
|
31
|
+
|
32
|
+
it 'returns an object representing the user' do
|
33
|
+
expect(user.first_name).to eq 'Jeremy'
|
34
|
+
expect(user.last_name).to eq 'Dev'
|
35
|
+
expect(user.gender).to eq 'male'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'given an unknown username' do
|
40
|
+
let(:username) { unknown_username }
|
41
|
+
it { expect{user}.to raise_error SocialNet::Facebook::UnknownUser }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'social_net/instagram'
|
3
|
+
|
4
|
+
describe SocialNet::Instagram::User, :vcr do
|
5
|
+
before :all do
|
6
|
+
SocialNet::Instagram.configure do |config|
|
7
|
+
if config.access_token.blank?
|
8
|
+
config.access_token = 'ACCESS_TOKEN'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:existing_username) { 'Collab' }
|
14
|
+
let(:unknown_username) { '01LjqweoojkjR' }
|
15
|
+
|
16
|
+
describe '.find_by' do
|
17
|
+
subject(:user) { SocialNet::Instagram::User.find_by username: username }
|
18
|
+
|
19
|
+
context 'given an existing (case-insensitive) username' do
|
20
|
+
let(:username) { existing_username }
|
21
|
+
|
22
|
+
it 'returns an object representing that user' do
|
23
|
+
expect(user.username).to eq 'collab'
|
24
|
+
expect(user.follower_count).to be_an Integer
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'given an unknown username' do
|
29
|
+
let(:username) { unknown_username }
|
30
|
+
it { expect(user).to be_nil }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.find_by!' do
|
35
|
+
subject(:user) { SocialNet::Instagram::User.find_by! username: username }
|
36
|
+
context 'given an existing (case-insensitive) username' do
|
37
|
+
let(:username) { existing_username }
|
38
|
+
|
39
|
+
it 'returns an object representing that user' do
|
40
|
+
expect(user.username).to eq 'collab'
|
41
|
+
expect(user.follower_count).to be_an Integer
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'given an unknown username' do
|
46
|
+
let(:username) { unknown_username }
|
47
|
+
it { expect{user}.to raise_error SocialNet::Instagram::UnknownUser }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'social_net/twitter'
|
3
|
+
|
4
|
+
describe SocialNet::Twitter::User, :vcr do
|
5
|
+
let(:unknown_screen_name) { '09hlQHE29534awe' }
|
6
|
+
let(:suspended_screen_name) { 'CodFatherLucas' }
|
7
|
+
let(:existing_screen_name) { 'collab' }
|
8
|
+
|
9
|
+
describe '.find_by' do
|
10
|
+
subject(:user) { SocialNet::Twitter::User.find_by screen_name: screen_name }
|
11
|
+
|
12
|
+
context 'given an existing (case-insensitive) screen name' do
|
13
|
+
let(:screen_name) { existing_screen_name }
|
14
|
+
|
15
|
+
it 'returns an object representing that user' do
|
16
|
+
expect(user.screen_name).to eq 'Collab'
|
17
|
+
expect(user.follower_count).to be_an Integer
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'given an unknown screen name' do
|
22
|
+
let(:screen_name) { unknown_screen_name }
|
23
|
+
it { expect(user).to be_nil }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'given a suspended screen name' do
|
27
|
+
let(:screen_name) { suspended_screen_name }
|
28
|
+
it { expect(user).to be_nil }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '.find_by!' do
|
33
|
+
subject(:user) { SocialNet::Twitter::User.find_by! screen_name: screen_name }
|
34
|
+
|
35
|
+
context 'given an existing (case-insensitive) screen name' do
|
36
|
+
let(:screen_name) { existing_screen_name }
|
37
|
+
|
38
|
+
it 'returns an object representing that user' do
|
39
|
+
expect(user.screen_name).to eq 'Collab'
|
40
|
+
expect(user.follower_count).to be_an Integer
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'given an unknown screen name' do
|
45
|
+
let(:screen_name) { unknown_screen_name }
|
46
|
+
it { expect{user}.to raise_error SocialNet::Twitter::UnknownUser }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'given a suspended screen name' do
|
50
|
+
let(:screen_name) { suspended_screen_name }
|
51
|
+
it { expect{user}.to raise_error SocialNet::Twitter::SuspendedUser }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '.where' do
|
56
|
+
context 'given multiple existing (case-insensitive) screen names' do
|
57
|
+
let(:screen_names) { ['brohemian6', existing_screen_name, suspended_screen_name, unknown_screen_name] }
|
58
|
+
subject(:users) { SocialNet::Twitter::User.where screen_name: screen_names }
|
59
|
+
|
60
|
+
it 'returns an array of objects representing those users' do
|
61
|
+
expect(users.map &:screen_name).to contain_exactly('Collab', 'brohemian6')
|
62
|
+
expect(users.map &:follower_count).to all(be_an Integer)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'given multiple unknown or suspended screen names' do
|
67
|
+
let(:screen_names) { [suspended_screen_name, unknown_screen_name] }
|
68
|
+
subject(:users) { SocialNet::Twitter::User.where screen_name: screen_names }
|
69
|
+
|
70
|
+
it 'returns an empty array' do
|
71
|
+
expect(users).to be_empty
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# @see https://dev.twitter.com/rest/reference/get/users/lookup
|
76
|
+
context 'given more screen names than allowed by Twitter' do
|
77
|
+
let(:screen_names) { ('a'..'z').map{|x| ('a'..'e').map{|y| "#{x}#{y}"}}.flatten }
|
78
|
+
subject(:users) { SocialNet::Twitter::User.where screen_name: screen_names }
|
79
|
+
|
80
|
+
it { expect{users}.to raise_error SocialNet::Twitter::TooManyUsers }
|
81
|
+
end
|
82
|
+
|
83
|
+
# @see https://dev.twitter.com/rest/public/rate-limits
|
84
|
+
context 'called more times than Twitter’s rate limit' do
|
85
|
+
|
86
|
+
before { expect(Time).to receive(:now).at_least(:once).and_return 12345678 }
|
87
|
+
let(:lookup_limit) { 60 }
|
88
|
+
let(:screen_names) { [existing_screen_name] }
|
89
|
+
subject(:user_sets) { (lookup_limit + 1).times.map do
|
90
|
+
SocialNet::Twitter::User.where screen_name: screen_names
|
91
|
+
end}
|
92
|
+
|
93
|
+
it 'waits for the rate limit to expire then continues' do
|
94
|
+
expect(user_sets.compact.size).to be > lookup_limit
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
3
|
+
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
+
SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
Coveralls::SimpleCov::Formatter
|
7
|
+
]
|
8
|
+
SimpleCov.start
|
9
|
+
|
10
|
+
require 'social_net'
|
11
|
+
Dir['./spec/support/**/*.rb'].each {|f| require f}
|
@@ -0,0 +1,106 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.instagram.com/v1/users/search?access_token=INSTAGRAM_ACCESS_TOKEN&q=Collab
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Content-Language:
|
22
|
+
- en
|
23
|
+
Content-Type:
|
24
|
+
- application/json; charset=utf-8
|
25
|
+
Expires:
|
26
|
+
- Sat, 01 Jan 2000 00:00:00 GMT
|
27
|
+
Pragma:
|
28
|
+
- no-cache
|
29
|
+
Date:
|
30
|
+
- Mon, 13 Mar 2017 22:40:44 GMT
|
31
|
+
Cache-Control:
|
32
|
+
- private, no-cache, no-store, must-revalidate
|
33
|
+
Vary:
|
34
|
+
- Cookie, Accept-Language, Accept-Encoding
|
35
|
+
X-Ratelimit-Limit:
|
36
|
+
- '500'
|
37
|
+
X-Ratelimit-Remaining:
|
38
|
+
- '482'
|
39
|
+
Set-Cookie:
|
40
|
+
- csrftoken=sJx8yhBIvtY9pJhFPBm5aLxZ82tlNgGP; expires=Mon, 12-Mar-2018 22:40:44
|
41
|
+
GMT; Max-Age=31449600; Path=/; Secure
|
42
|
+
Connection:
|
43
|
+
- keep-alive
|
44
|
+
Content-Length:
|
45
|
+
- '260'
|
46
|
+
body:
|
47
|
+
encoding: ASCII-8BIT
|
48
|
+
string: '{"meta": {"code": 200}, "data": [{"bio": "Funemployed \ud83d\ude0e
|
49
|
+
Twitter/Musically: @collab \ud83e\udd18", "full_name": "Collab", "website":
|
50
|
+
"http://bit.ly/2nolE10", "profile_picture": "https://scontent.cdninstagram.com/t51.2885-19/s150x150/13414208_199612667102550_1239056879_a.jpg",
|
51
|
+
"username": "collab", "id": "487786346"}]}'
|
52
|
+
http_version:
|
53
|
+
recorded_at: Mon, 13 Mar 2017 22:40:44 GMT
|
54
|
+
- request:
|
55
|
+
method: get
|
56
|
+
uri: https://api.instagram.com/v1/users/487786346?access_token=INSTAGRAM_ACCESS_TOKEN
|
57
|
+
body:
|
58
|
+
encoding: US-ASCII
|
59
|
+
string: ''
|
60
|
+
headers:
|
61
|
+
Accept-Encoding:
|
62
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
63
|
+
Accept:
|
64
|
+
- "*/*"
|
65
|
+
User-Agent:
|
66
|
+
- Ruby
|
67
|
+
response:
|
68
|
+
status:
|
69
|
+
code: 200
|
70
|
+
message: OK
|
71
|
+
headers:
|
72
|
+
Pragma:
|
73
|
+
- no-cache
|
74
|
+
Content-Language:
|
75
|
+
- en
|
76
|
+
Expires:
|
77
|
+
- Sat, 01 Jan 2000 00:00:00 GMT
|
78
|
+
X-Ratelimit-Limit:
|
79
|
+
- '500'
|
80
|
+
Content-Type:
|
81
|
+
- application/json; charset=utf-8
|
82
|
+
X-Ratelimit-Remaining:
|
83
|
+
- '481'
|
84
|
+
Date:
|
85
|
+
- Mon, 13 Mar 2017 22:40:44 GMT
|
86
|
+
Vary:
|
87
|
+
- Cookie, Accept-Language, Accept-Encoding
|
88
|
+
Cache-Control:
|
89
|
+
- private, no-cache, no-store, must-revalidate
|
90
|
+
Set-Cookie:
|
91
|
+
- csrftoken=ZQU37JFc9ra6IQo1cWoC0xw78IcGwbYI; expires=Mon, 12-Mar-2018 22:40:44
|
92
|
+
GMT; Max-Age=31449600; Path=/; Secure
|
93
|
+
Connection:
|
94
|
+
- keep-alive
|
95
|
+
Content-Length:
|
96
|
+
- '287'
|
97
|
+
body:
|
98
|
+
encoding: ASCII-8BIT
|
99
|
+
string: '{"meta": {"code": 200}, "data": {"counts": {"followed_by": 23286, "media":
|
100
|
+
627, "follows": 369}, "profile_picture": "https://scontent.cdninstagram.com/t51.2885-19/s150x150/13414208_199612667102550_1239056879_a.jpg",
|
101
|
+
"username": "collab", "id": "487786346", "website": "http://bit.ly/2nolE10",
|
102
|
+
"bio": "Funemployed \ud83d\ude0e Twitter/Musically: @collab \ud83e\udd18",
|
103
|
+
"full_name": "Collab"}}'
|
104
|
+
http_version:
|
105
|
+
recorded_at: Mon, 13 Mar 2017 22:40:44 GMT
|
106
|
+
recorded_with: VCR 2.9.3
|
data/spec/support/cassettes/SocialNet_Instagram_Models_User/_find_by/given_an_unknown_username/.yml
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.instagram.com/v1/users/search?access_token=INSTAGRAM_ACCESS_TOKEN&q=01LjqweoojkjR
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Mon, 13 Mar 2017 22:40:44 GMT
|
23
|
+
X-Ratelimit-Limit:
|
24
|
+
- '500'
|
25
|
+
Content-Language:
|
26
|
+
- en
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Expires:
|
30
|
+
- Sat, 01 Jan 2000 00:00:00 GMT
|
31
|
+
Cache-Control:
|
32
|
+
- private, no-cache, no-store, must-revalidate
|
33
|
+
Pragma:
|
34
|
+
- no-cache
|
35
|
+
Vary:
|
36
|
+
- Cookie, Accept-Language
|
37
|
+
X-Ratelimit-Remaining:
|
38
|
+
- '480'
|
39
|
+
Set-Cookie:
|
40
|
+
- csrftoken=DX2UJsWmSUGEDG4dpYP2kANHXRQAa96c; expires=Mon, 12-Mar-2018 22:40:44
|
41
|
+
GMT; Max-Age=31449600; Path=/; Secure
|
42
|
+
Connection:
|
43
|
+
- keep-alive
|
44
|
+
Content-Length:
|
45
|
+
- '35'
|
46
|
+
body:
|
47
|
+
encoding: UTF-8
|
48
|
+
string: '{"data": [], "meta": {"code": 200}}'
|
49
|
+
http_version:
|
50
|
+
recorded_at: Mon, 13 Mar 2017 22:40:44 GMT
|
51
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,106 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.instagram.com/v1/users/search?access_token=INSTAGRAM_ACCESS_TOKEN&q=Collab
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Expires:
|
22
|
+
- Sat, 01 Jan 2000 00:00:00 GMT
|
23
|
+
Content-Language:
|
24
|
+
- en
|
25
|
+
Date:
|
26
|
+
- Mon, 13 Mar 2017 22:40:45 GMT
|
27
|
+
Cache-Control:
|
28
|
+
- private, no-cache, no-store, must-revalidate
|
29
|
+
X-Ratelimit-Remaining:
|
30
|
+
- '479'
|
31
|
+
Content-Type:
|
32
|
+
- application/json; charset=utf-8
|
33
|
+
X-Ratelimit-Limit:
|
34
|
+
- '500'
|
35
|
+
Vary:
|
36
|
+
- Cookie, Accept-Language, Accept-Encoding
|
37
|
+
Pragma:
|
38
|
+
- no-cache
|
39
|
+
Set-Cookie:
|
40
|
+
- csrftoken=dOXi0A6wyGvTVe3jfGPR8SwJvgVcQVF7; expires=Mon, 12-Mar-2018 22:40:45
|
41
|
+
GMT; Max-Age=31449600; Path=/; Secure
|
42
|
+
Connection:
|
43
|
+
- keep-alive
|
44
|
+
Content-Length:
|
45
|
+
- '260'
|
46
|
+
body:
|
47
|
+
encoding: ASCII-8BIT
|
48
|
+
string: '{"data": [{"bio": "Funemployed \ud83d\ude0e Twitter/Musically: @collab
|
49
|
+
\ud83e\udd18", "full_name": "Collab", "website": "http://bit.ly/2nolE10",
|
50
|
+
"profile_picture": "https://scontent.cdninstagram.com/t51.2885-19/s150x150/13414208_199612667102550_1239056879_a.jpg",
|
51
|
+
"id": "487786346", "username": "collab"}], "meta": {"code": 200}}'
|
52
|
+
http_version:
|
53
|
+
recorded_at: Mon, 13 Mar 2017 22:40:45 GMT
|
54
|
+
- request:
|
55
|
+
method: get
|
56
|
+
uri: https://api.instagram.com/v1/users/487786346?access_token=INSTAGRAM_ACCESS_TOKEN
|
57
|
+
body:
|
58
|
+
encoding: US-ASCII
|
59
|
+
string: ''
|
60
|
+
headers:
|
61
|
+
Accept-Encoding:
|
62
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
63
|
+
Accept:
|
64
|
+
- "*/*"
|
65
|
+
User-Agent:
|
66
|
+
- Ruby
|
67
|
+
response:
|
68
|
+
status:
|
69
|
+
code: 200
|
70
|
+
message: OK
|
71
|
+
headers:
|
72
|
+
Expires:
|
73
|
+
- Sat, 01 Jan 2000 00:00:00 GMT
|
74
|
+
Content-Language:
|
75
|
+
- en
|
76
|
+
Cache-Control:
|
77
|
+
- private, no-cache, no-store, must-revalidate
|
78
|
+
Pragma:
|
79
|
+
- no-cache
|
80
|
+
X-Ratelimit-Limit:
|
81
|
+
- '500'
|
82
|
+
Date:
|
83
|
+
- Mon, 13 Mar 2017 22:40:45 GMT
|
84
|
+
Vary:
|
85
|
+
- Cookie, Accept-Language, Accept-Encoding
|
86
|
+
X-Ratelimit-Remaining:
|
87
|
+
- '478'
|
88
|
+
Content-Type:
|
89
|
+
- application/json; charset=utf-8
|
90
|
+
Set-Cookie:
|
91
|
+
- csrftoken=zpJ7PfW0ggBGglMrxHOG6wGSCTUJnIWB; expires=Mon, 12-Mar-2018 22:40:45
|
92
|
+
GMT; Max-Age=31449600; Path=/; Secure
|
93
|
+
Connection:
|
94
|
+
- keep-alive
|
95
|
+
Content-Length:
|
96
|
+
- '290'
|
97
|
+
body:
|
98
|
+
encoding: ASCII-8BIT
|
99
|
+
string: '{"data": {"bio": "Funemployed \ud83d\ude0e Twitter/Musically: @collab
|
100
|
+
\ud83e\udd18", "counts": {"followed_by": 23286, "media": 627, "follows": 369},
|
101
|
+
"website": "http://bit.ly/2nolE10", "full_name": "Collab", "username": "collab",
|
102
|
+
"profile_picture": "https://scontent.cdninstagram.com/t51.2885-19/s150x150/13414208_199612667102550_1239056879_a.jpg",
|
103
|
+
"id": "487786346"}, "meta": {"code": 200}}'
|
104
|
+
http_version:
|
105
|
+
recorded_at: Mon, 13 Mar 2017 22:40:45 GMT
|
106
|
+
recorded_with: VCR 2.9.3
|