Class: Zernio::RedditSearchApi

Inherits:
Object
  • Object
show all
Defined in:
lib/zernio-sdk/api/reddit_search_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ RedditSearchApi

Returns a new instance of RedditSearchApi.



19
20
21
# File 'lib/zernio-sdk/api/reddit_search_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/zernio-sdk/api/reddit_search_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_reddit_feed(account_id, opts = {}) ⇒ SearchReddit200Response

Get subreddit feed Fetch posts from a subreddit feed. Supports sorting, time filtering, and cursor-based pagination.

Parameters:

  • account_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :subreddit (String)
  • :sort (String) — default: default to 'hot'
  • :limit (Integer) — default: default to 25
  • :after (String)
  • :t (String)

Returns:



32
33
34
35
# File 'lib/zernio-sdk/api/reddit_search_api.rb', line 32

def get_reddit_feed(, opts = {})
  data, _status_code, _headers = get_reddit_feed_with_http_info(, opts)
  data
end

#get_reddit_feed_with_http_info(account_id, opts = {}) ⇒ Array<(SearchReddit200Response, Integer, Hash)>

Get subreddit feed Fetch posts from a subreddit feed. Supports sorting, time filtering, and cursor-based pagination.

Parameters:

  • account_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :subreddit (String)
  • :sort (String) — default: default to 'hot'
  • :limit (Integer) — default: default to 25
  • :after (String)
  • :t (String)

Returns:

  • (Array<(SearchReddit200Response, Integer, Hash)>)

    SearchReddit200Response data, response status code and response headers



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/zernio-sdk/api/reddit_search_api.rb', line 47

def get_reddit_feed_with_http_info(, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RedditSearchApi.get_reddit_feed ...'
  end
  # verify the required parameter 'account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'account_id' when calling RedditSearchApi.get_reddit_feed"
  end
  allowable_values = ["hot", "new", "top", "rising"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling RedditSearchApi.get_reddit_feed, must be smaller than or equal to 100.'
  end

  allowable_values = ["hour", "day", "week", "month", "year", "all"]
  if @api_client.config.client_side_validation && opts[:'t'] && !allowable_values.include?(opts[:'t'])
    fail ArgumentError, "invalid value for \"t\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/v1/reddit/feed'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'accountId'] = 
  query_params[:'subreddit'] = opts[:'subreddit'] if !opts[:'subreddit'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
  query_params[:'t'] = opts[:'t'] if !opts[:'t'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'SearchReddit200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"RedditSearchApi.get_reddit_feed",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RedditSearchApi#get_reddit_feed\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#search_reddit(account_id, q, opts = {}) ⇒ SearchReddit200Response

Search posts Search Reddit posts using a connected account. Optionally scope to a specific subreddit.

Parameters:

  • account_id (String)
  • q (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :subreddit (String)
  • :restrict_sr (String)
  • :sort (String) — default: default to 'new'
  • :limit (Integer) — default: default to 25
  • :after (String)

Returns:



124
125
126
127
# File 'lib/zernio-sdk/api/reddit_search_api.rb', line 124

def search_reddit(, q, opts = {})
  data, _status_code, _headers = search_reddit_with_http_info(, q, opts)
  data
end

#search_reddit_with_http_info(account_id, q, opts = {}) ⇒ Array<(SearchReddit200Response, Integer, Hash)>

Search posts Search Reddit posts using a connected account. Optionally scope to a specific subreddit.

Parameters:

  • account_id (String)
  • q (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :subreddit (String)
  • :restrict_sr (String)
  • :sort (String) — default: default to 'new'
  • :limit (Integer) — default: default to 25
  • :after (String)

Returns:

  • (Array<(SearchReddit200Response, Integer, Hash)>)

    SearchReddit200Response data, response status code and response headers



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/zernio-sdk/api/reddit_search_api.rb', line 140

def search_reddit_with_http_info(, q, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RedditSearchApi.search_reddit ...'
  end
  # verify the required parameter 'account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'account_id' when calling RedditSearchApi.search_reddit"
  end
  # verify the required parameter 'q' is set
  if @api_client.config.client_side_validation && q.nil?
    fail ArgumentError, "Missing the required parameter 'q' when calling RedditSearchApi.search_reddit"
  end
  allowable_values = ["0", "1"]
  if @api_client.config.client_side_validation && opts[:'restrict_sr'] && !allowable_values.include?(opts[:'restrict_sr'])
    fail ArgumentError, "invalid value for \"restrict_sr\", must be one of #{allowable_values}"
  end
  allowable_values = ["relevance", "hot", "top", "new", "comments"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling RedditSearchApi.search_reddit, must be smaller than or equal to 100.'
  end

  # resource path
  local_var_path = '/v1/reddit/search'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'accountId'] = 
  query_params[:'q'] = q
  query_params[:'subreddit'] = opts[:'subreddit'] if !opts[:'subreddit'].nil?
  query_params[:'restrict_sr'] = opts[:'restrict_sr'] if !opts[:'restrict_sr'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'SearchReddit200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"RedditSearchApi.search_reddit",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RedditSearchApi#search_reddit\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end