giphyrb 0.1.1 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d219e3e52055561188677535177d1526b5cd04eb
4
- data.tar.gz: 6c14791d1ee93b2eeace31726f94473edbcaa3c7
3
+ metadata.gz: 3269d612a4d65ab52aee537e67361d5c6442ccc8
4
+ data.tar.gz: 4a2e1a9c3bec82d830a1840675de27842d9fe47b
5
5
  SHA512:
6
- metadata.gz: bad7c46279544a65b77076a43105ae91af419159ab1e3531f7e16581393f7bf710aa0bd74f8f8468a3e764b7c5113311aa921f919bac741cf23ce98b49cce8e7
7
- data.tar.gz: 6fc5bc7a42372048ae7d7d488d8a771325b70d6107b57d43bb318b3410dbfd995903120a1b38c122f9392aa7a00b56e144b6378fd7a86aeaeeea071b7f478618
6
+ metadata.gz: 7d29b2607aa8d52d8365e6c4a23a7bee4a8b8cf93a298bf630bf7581d2da4c72ef79f1e291e7a39c204340dbe6aecce13726e4e87c23bf90a4c58f29bcc97f1d
7
+ data.tar.gz: ad6fc01e3b4d2af3f21839a9df5b6ae860c10d8138dc63cc45dfeaae2e063f92cb9464997276b806bc4b0330315e8f2d2be20eac24afbf7025b0bc97b5238f28
@@ -0,0 +1 @@
1
+ *.gem
data/README.MD CHANGED
@@ -62,8 +62,7 @@ giphy.from_ids(ids=[])
62
62
 
63
63
  See [LICENSE](https://github.com/Whaxion/giphyrb/blob/master/LICENSE) for details.
64
64
 
65
- ##TODO list
65
+ ## TODO list
66
66
 
67
- - Add Sticker API
68
- - Document code
69
- - Improve user experience (new syntax)
67
+ - Add Stickers packs
68
+ - Improve user experience (new syntax)
@@ -2,7 +2,7 @@ require_relative 'lib/giphyrb'
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.summary = 'Giphy API wrapper'
5
- s.description = 'A simple Giphy API Wrapper'
5
+ s.description = GiphyRB::Giphy::DESCRIPTION
6
6
  s.authors = ['Whaxion']
7
7
  s.email = ['whaxion@gmail.com']
8
8
  s.homepage = 'http://github.com/whaxion/giphyrb'
@@ -11,7 +11,8 @@ module GiphyRB
11
11
 
12
12
  ENDPOINT = 'http://api.giphy.com'
13
13
  API_VERSION = 'v1'
14
- VERSION = '0.1.1'
14
+ VERSION = '0.2'
15
+ DESCRIPTION ='A simple Giphy API Wrapper supporting Stickers API (except Stickers pack)'
15
16
 
16
17
  # Initialize the client
17
18
  def initialize(api_key:true)
@@ -19,14 +20,12 @@ module GiphyRB
19
20
  end
20
21
 
21
22
  # Search all GIPHY GIFs for a word or phrase. Punctuation will be stripped and ignored. Use a plus or url encode for phrases.
22
- # == Arguments
23
- # +query+:: Search query term or phrase
24
- # +limit+:: The maximum number of records to return (default=5)
25
- # +offset+:: An optional results offset. (default=0)
26
- # +rating+:: Filters results by specified rating (default=g)
27
- # +lang+:: Specify default language for regional content; use a 2-letter ISO 639-1 language code (default=nil)
28
- # == Return
29
- # Responses::Search
23
+ # @param query [String] Search query term or phrase
24
+ # @param limit [Int] The maximum number of records to return (default=5)
25
+ # @param offset [Int] An optional results offset. (default=0)
26
+ # @param rating [String] Filters results by specified rating (default=g)
27
+ # @param lang [String] Specify default language for regional content; use a 2-letter ISO 639-1 language code (default=nil)
28
+ # @return [Responses::Search]
30
29
  def search(query, limit=5, offset=0, rating='g', lang=nil)
31
30
  params = {:q => query, :limit => limit.to_i, :offset => offset.to_i, :rating => rating}
32
31
  params[:lang] = lang unless lang == nil
@@ -35,12 +34,10 @@ module GiphyRB
35
34
  end
36
35
 
37
36
  # Fetch GIFs currently trending online. Hand curated by the GIPHY editorial team. The data returned mirrors the GIFs showcased on the GIPHY homepage.
38
- # == Arguments
39
- # +limit+:: The maximum number of records to return (default=5)
40
- # +offset+:: An optional results offset. (default=0)
41
- # +rating+:: Filters results by specified rating (default=g)
42
- # == Return
43
- # Responses::Trending
37
+ # @param limit [Int] The maximum number of records to return (default=5)
38
+ # @param offset [Int] An optional results offset. (default=0)
39
+ # @param rating [String] Filters results by specified rating (default=g)
40
+ # @return [Responses::Trending]
44
41
  def trending(limit=5, offset=0, rating='g')
45
42
  params = {:limit => limit.to_i, :offset => offset.to_i, :rating => rating}
46
43
  result = request'gifs/trending', params
@@ -48,10 +45,8 @@ module GiphyRB
48
45
  end
49
46
 
50
47
  # The translate API draws on search, but uses the GIPHY special sauce to handle translating from one vocabulary to another. In this case, words and phrases to GIFs.
51
- # == Arguments
52
- # +string+:: Search term
53
- # == Return
54
- # Responses::Translate
48
+ # @param string [String] Search term
49
+ # @return [Responses::Translate]
55
50
  def translate(string)
56
51
  params = {:s => string}
57
52
  result = request'gifs/translate', params
@@ -59,11 +54,9 @@ module GiphyRB
59
54
  end
60
55
 
61
56
  # Returns a random GIF, limited by tag. Excluding the tag parameter will return a random GIF from the GIPHY catalog.
62
- # == Arguments
63
- # +tag+:: Filters results by specified tag
64
- # +rating+:: Filters results by specified rating (default=g)
65
- # == Return
66
- # Responses::Random
57
+ # @param tag [String] Filters results by specified tag
58
+ # @param rating [String] Filters results by specified rating (default=g)
59
+ # @return [Responses::Random]
67
60
  def random(tag=nil, rating='g')
68
61
  params = {:tag => tag, :rating => rating}
69
62
  result = request'gifs/random', params
@@ -71,10 +64,8 @@ module GiphyRB
71
64
  end
72
65
 
73
66
  # Returns a GIF given that GIF's unique ID.
74
- # == Arguments
75
- # +id+:: Filters results by specified GIF ID
76
- # == Return
77
- # Response
67
+ # @param id [String] Filters results by specified GIF ID
68
+ # @return [Response]
78
69
  def from_id(id)
79
70
  params = {}
80
71
  result = request'gifs/' + id.to_s, params
@@ -82,10 +73,8 @@ module GiphyRB
82
73
  end
83
74
 
84
75
  # A multiget version of the get GIF by ID endpoint
85
- # == Arguments
86
- # +ids+:: Filters results by specified GIF IDs (Array)
87
- # == Return
88
- # Response
76
+ # @param ids [Array<String>] Filters results by specified GIF IDs
77
+ # @return [Response]
89
78
  def from_ids(ids=[])
90
79
  ids = Array(ids)
91
80
  ids = ids.join ','
@@ -94,6 +83,50 @@ module GiphyRB
94
83
  Response.new(result)
95
84
  end
96
85
 
86
+ # Replicates the functionality and requirements of the classic GIPHY search, but returns animated stickers rather than GIFs.
87
+ # @param query [String] Search query term or phrase
88
+ # @param limit [Int] The maximum number of records to return (default=5)
89
+ # @param offset [Int] An optional results offset. (default=0)
90
+ # @param rating [String] Filters results by specified rating (default=g)
91
+ # @param lang [String] Specify default language for regional content; use a 2-letter ISO 639-1 language code (default=nil)
92
+ # @return [Responses::Search]
93
+ def sticker_search(query, limit=5, offset=0, rating='g', lang=nil)
94
+ params = {:q => query, :limit => limit.to_i, :offset => offset.to_i, :rating => rating}
95
+ params[:lang] = lang unless lang == nil
96
+ result = request'stickers/search', params
97
+ Responses::Search.new(result, query)
98
+ end
99
+
100
+ # Fetch Stickers currently trending online. Hand curated by the GIPHY editorial team.
101
+ # @param limit [Int] The maximum number of records to return (default=5)
102
+ # @param offset [Int] An optional results offset. (default=0)
103
+ # @param rating [String] Filters results by specified rating (default=g)
104
+ # @return [Responses::Trending]
105
+ def sticker_trending(limit=5, offset=0, rating='g')
106
+ params = {:limit => limit.to_i, :offset => offset.to_i, :rating => rating}
107
+ result = request'stickers/trending', params
108
+ Responses::Trending.new(result)
109
+ end
110
+
111
+ # The translate API draws on search, but uses the GIPHY special sauce to handle translating from one vocabulary to another. In this case, words and phrases to GIFs.
112
+ # @param string [String] Search term
113
+ # @return [Responses::Translate]
114
+ def sticker_translate(string)
115
+ params = {:s => string}
116
+ result = request'stickers/translate', params
117
+ Responses::Translate.new(result)
118
+ end
119
+
120
+ # Returns a random Sticker, limited by tag. Excluding the tag parameter will return a random Sticker from the GIPHY catalog.
121
+ # @param tag [String] Filters results by specified tag
122
+ # @param rating [String] Filters results by specified rating (default=g)
123
+ # @return [Responses::Random]
124
+ def sticker_random(tag=nil, rating='g')
125
+ params = {:tag => tag, :rating => rating}
126
+ result = request'stickers/random', params
127
+ Responses::Random.new(result, tag)
128
+ end
129
+
97
130
  private
98
131
 
99
132
  def request(url, params)
metadata CHANGED
@@ -1,22 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: giphyrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Whaxion
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-21 00:00:00.000000000 Z
11
+ date: 2017-12-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: A simple Giphy API Wrapper
13
+ description: A simple Giphy API Wrapper supporting Stickers API (except Stickers pack)
14
14
  email:
15
15
  - whaxion@gmail.com
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".gitignore"
20
21
  - LICENSE
21
22
  - README.MD
22
23
  - giphyrb.gemspec