instaclient 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0dc08d5773bbfd302854c66e511d2a5f0b90d985
4
- data.tar.gz: 30ec6abf0d94553d3231d409695caf750899a903
3
+ metadata.gz: 3d05f00211219cdd7bddaf3d632e01b93698b8e3
4
+ data.tar.gz: 254a0f9b161ede82cb8a67db5d7b09d5d58508b8
5
5
  SHA512:
6
- metadata.gz: 202e3b5e2f5de1925eb0121b4fa3bb3b8d85b3d01eaf106811cd007fae6a559610492aff6cc6a88438fba4a9ca4087c97fad85ace5e4ceb9c931b078fd72d520
7
- data.tar.gz: b9fc8385a994ea166234e3be289ba079daa8fb93b5a19f672135b55ba1c0deaad0f976bc5a4520f219e7cd21f98e65640cbba43ccd68a31b21f452a6f5145ccb
6
+ metadata.gz: f5e04b7ebd44365312c523d38aabc6a96e780c9fd1a07889243fff6d6e52e8635911b6d2a82a57a67deed87b470cb9ebbefc50b2d10fbb93fee42b5cbf79de18
7
+ data.tar.gz: 137c8e97fcb9a27ac061ccffc5fbb38f99718d4e093185d71573cf3b84c4e43a3ea9aec35e106d513101a8aede3b49088c2a9b2ec3213da834b2f144c748383f
data/README.md CHANGED
@@ -9,8 +9,8 @@ Usage
9
9
 
10
10
  ```
11
11
  require 'instaclient'
12
-
13
12
  client = Instaclient::Client.new(my_client_id, my_client_secret)
13
+
14
14
  result = client.recent(user_id, count)
15
15
 
16
16
  result.each do |media|
@@ -19,6 +19,15 @@ Usage
19
19
  puts "Image: #{media.image_url(:standard_resolution)}"
20
20
  ...
21
21
  end
22
+
23
+ embed = client.embed("https://instagram.com/p/somemedia/")
24
+
25
+ embed.html
26
+ #=> "<blockquote ..."
27
+ embed.title
28
+ #=> "media title"
29
+ embed.author
30
+ #=> "author name"
22
31
  ```
23
32
 
24
33
  Methods
@@ -1,4 +1,3 @@
1
- require 'instaclient/models/media'
2
1
  require 'instaclient/client'
3
2
 
4
3
  module Instaclient
@@ -1,5 +1,7 @@
1
1
  require 'json'
2
2
  require 'typhoeus'
3
+ require 'instaclient/models/media'
4
+ require 'instaclient/models/embed'
3
5
 
4
6
  module Instaclient
5
7
  class Client
@@ -19,9 +21,16 @@ module Instaclient
19
21
  end
20
22
  end
21
23
 
24
+ def embed(media_url)
25
+ url = EMBED_ENDPOINT % { url: media_url }
26
+ data = parsed_response(url)
27
+ Models::Embed.new(data)
28
+ end
29
+
22
30
  private
23
31
 
24
32
  RECENT_MEDIA_ENDPOINT = "https://api.instagram.com/v1/users/%{user_id}/media/recent/?count=%{count}&client_id=%{client_id}"
33
+ EMBED_ENDPOINT = "http://api.instagram.com/oembed?url=%{url}"
25
34
 
26
35
  def make_request(url)
27
36
  Typhoeus.get(url).tap do |response|
@@ -0,0 +1,36 @@
1
+ module Instaclient
2
+ module Models
3
+ class Embed
4
+ attr_accessor :raw
5
+
6
+ def initialize(data)
7
+ @raw = data
8
+ end
9
+
10
+ def author_name
11
+ raw["author_name"]
12
+ end
13
+
14
+ def title
15
+ raw["title"]
16
+ end
17
+
18
+ def html
19
+ raw["html"]
20
+ end
21
+
22
+ def thumbnail
23
+ raw["thumbnail_url"]
24
+ end
25
+
26
+ def author_url
27
+ raw["author_url"]
28
+ end
29
+
30
+ def author_id
31
+ raw["author_id"]
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -1,3 +1,3 @@
1
1
  module Instaclient
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instaclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Scolari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-04 00:00:00.000000000 Z
11
+ date: 2015-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -91,6 +91,7 @@ files:
91
91
  - README.md
92
92
  - lib/instaclient.rb
93
93
  - lib/instaclient/client.rb
94
+ - lib/instaclient/models/embed.rb
94
95
  - lib/instaclient/models/media.rb
95
96
  - lib/instaclient/version.rb
96
97
  homepage: https://github.com/tscolari/instaclient