_id
stringlengths 2
6
| title
stringlengths 9
130
| partition
stringclasses 3
values | text
stringlengths 66
10.5k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q25400 | RediSearchRails.ClassMethods.redi_search_schema | validation | def redi_search_schema(schema)
@schema = schema.to_a.flatten
@fields = schema.keys
@model = self.name.constantize
@index_name = @model.to_s
@score = 1
end | ruby | {
"resource": ""
} |
q25401 | RediSearchRails.ClassMethods.ft_search_count | validation | def ft_search_count(args)
ft_search(args).first
rescue Exception => e
Rails.logger.error e if defined? Rails
return e.message
end | ruby | {
"resource": ""
} |
q25402 | RediSearchRails.ClassMethods.ft_add_all | validation | def ft_add_all
@model.all.each {|record| ft_add(record: record) }
ft_optimize
rescue Exception => e
Rails.logger.error e if defined? Rails
return e.message
end | ruby | {
"resource": ""
} |
q25403 | RediSearchRails.ClassMethods.ft_add | validation | def ft_add record:
fields = []
@fields.each { |field| fields.push(field, record.send(field)) }
REDI_SEARCH.call('FT.ADD', @index_name, record.to_global_id.to_s, @score,
'REPLACE',
'FIELDS', fields
#'NOSAVE', 'PAYLOAD', 'LANGUAGE'
)
rescue Exception => e
Rails.logger.error e if defined? Rails
return e.message
end | ruby | {
"resource": ""
} |
q25404 | RediSearchRails.ClassMethods.ft_addhash | validation | def ft_addhash redis_key:
REDI_SEARCH.call('FT.ADDHASH', @index_name, redis_key, @score, 'REPLACE')
rescue Exception => e
Rails.logger.error e if defined? Rails
return e.message
end | ruby | {
"resource": ""
} |
q25405 | RediSearchRails.ClassMethods.ft_del_all | validation | def ft_del_all
@model.all.each {|record| ft_del(record: record) }
ft_optimize
rescue Exception => e
Rails.logger.error e if defined? Rails
return e.message
end | ruby | {
"resource": ""
} |
q25406 | RediSearchRails.ClassMethods.ft_del | validation | def ft_del record:
doc_id = record.to_global_id
REDI_SEARCH.call('FT.DEL', @index_name, doc_id)
rescue Exception => e
Rails.logger.error e if defined? Rails
return e.message
end | ruby | {
"resource": ""
} |
q25407 | RediSearchRails.ClassMethods.ft_info | validation | def ft_info
REDI_SEARCH.call('FT.INFO', @index_name)
rescue Exception => e
Rails.logger.error e if defined? Rails
return e.message
end | ruby | {
"resource": ""
} |
q25408 | RediSearchRails.ClassMethods.ft_sugadd_all | validation | def ft_sugadd_all (attribute:)
@model.all.each {|record| ft_sugadd(record: record, attribute: attribute) }
rescue Exception => e
Rails.logger.error e if defined? Rails
return e.message
end | ruby | {
"resource": ""
} |
q25409 | RediSearchRails.ClassMethods.ft_sugadd | validation | def ft_sugadd (record:, attribute:, score: 1)
# => combine model with attribute to create unique key like user_name
key = "#{@model.to_s}:#{attribute}"
string = record.send(attribute)
REDI_SEARCH.call('FT.SUGADD', key, string, score)
# => INCR
rescue Exception => e
Rails.logger.error e if defined? Rails
return e.message
end | ruby | {
"resource": ""
} |
q25410 | RediSearchRails.ClassMethods.ft_sugget | validation | def ft_sugget (attribute:, prefix:)
key = "#{@model}:#{attribute}"
REDI_SEARCH.call('FT.SUGGET', key, prefix)
rescue Exception => e
Rails.logger.error e if defined? Rails
return e.message
end | ruby | {
"resource": ""
} |
q25411 | RediSearchRails.ClassMethods.ft_sugdel_all | validation | def ft_sugdel_all (attribute:)
@model.all.each {|record| ft_sugdel(record: record, attribute: attribute) }
rescue Exception => e
Rails.logger.error e if defined? Rails
return e.message
end | ruby | {
"resource": ""
} |
q25412 | RediSearchRails.ClassMethods.ft_suglen | validation | def ft_suglen (attribute:)
key = "#{@model}:#{attribute}"
REDI_SEARCH.call('FT.SUGLEN', key)
rescue Exception => e
Rails.logger.error e if defined? Rails
return e.message
end | ruby | {
"resource": ""
} |
q25413 | Reality.Zapwhite.run | validation | def run
normalize_count = 0
if generate_gitattributes?
output_options = {:prefix => '# DO NOT EDIT: File is auto-generated', :normalize => true}
new_gitattributes = generate_gitattributes!
new_content = new_gitattributes.as_file_contents(output_options)
old_content = File.exist?(@attributes.attributes_file) ? IO.read(@attributes.attributes_file) : nil
if new_content != old_content
@attributes = new_gitattributes
if check_only?
puts 'Non-normalized .gitattributes file'
else
puts 'Fixing: .gitattributes'
@attributes.write(output_options)
end
normalize_count += 1
end
end
files = {}
collect_file_attributes(files)
files.each_pair do |filename, config|
full_filename = "#{@base_directory}/#{filename}"
original_bin_content = File.binread(full_filename)
encoding = config[:encoding].nil? ? 'utf-8' : config[:encoding].gsub(/^UTF/,'utf-')
content = File.read(full_filename, :encoding => "bom|#{encoding}")
content =
config[:dos] ?
clean_dos_whitespace(filename, content, config[:eofnl], config[:allow_empty]) :
clean_whitespace(filename, content, config[:eofnl], config[:allow_empty])
if config[:nodupnl]
while content.gsub!(/\n\n\n/, "\n\n")
# Keep removing duplicate new lines till they have gone
end
end
if content.bytes != original_bin_content.bytes
normalize_count += 1
if check_only?
puts "Non-normalized whitespace in #{filename}"
else
puts "Fixing: #{filename}"
File.open(full_filename, 'wb') do |out|
out.write content
end
end
end
end
normalize_count
end | ruby | {
"resource": ""
} |
q25414 | Reality.Zapwhite.in_dir | validation | def in_dir(dir, &block)
original_dir = Dir.pwd
begin
Dir.chdir(dir)
block.call
ensure
Dir.chdir(original_dir)
end
end | ruby | {
"resource": ""
} |
q25415 | Fridge.RailsHelpers.validate_token | validation | def validate_token(access_token)
validator = Fridge.configuration.validator
validator.call(access_token) && access_token
rescue
false
end | ruby | {
"resource": ""
} |
q25416 | Fridge.RailsHelpers.validate_token! | validation | def validate_token!(access_token)
validator = Fridge.configuration.validator
if validator.call(access_token)
access_token
else
raise InvalidToken, 'Rejected by validator'
end
end | ruby | {
"resource": ""
} |
q25417 | CreateSend.Subscriber.update | validation | def update(new_email_address, name, custom_fields, resubscribe,
consent_to_track, restart_subscription_based_autoresponders=false)
options = {
:query => { :email => @email_address },
:body => {
:EmailAddress => new_email_address,
:Name => name,
:CustomFields => custom_fields,
:Resubscribe => resubscribe,
:RestartSubscriptionBasedAutoresponders =>
restart_subscription_based_autoresponders,
:ConsentToTrack => consent_to_track }.to_json }
put "/subscribers/#{@list_id}.json", options
# Update @email_address, so this object can continue to be used reliably
@email_address = new_email_address
end | ruby | {
"resource": ""
} |
q25418 | CreateSend.Subscriber.history | validation | def history
options = { :query => { :email => @email_address } }
response = cs_get "/subscribers/#{@list_id}/history.json", options
response.map{|item| Hashie::Mash.new(item)}
end | ruby | {
"resource": ""
} |
q25419 | CreateSend.Segment.subscribers | validation | def subscribers(date="", page=1, page_size=1000, order_field="email",
order_direction="asc", include_tracking_preference=false)
options = { :query => {
:date => date,
:page => page,
:pagesize => page_size,
:orderfield => order_field,
:orderdirection => order_direction,
:includetrackingpreference => include_tracking_preference } }
response = get "active", options
Hashie::Mash.new(response)
end | ruby | {
"resource": ""
} |
q25420 | CreateSend.Template.update | validation | def update(name, html_url, zip_url)
options = { :body => {
:Name => name,
:HtmlPageURL => html_url,
:ZipFileURL => zip_url }.to_json }
put "/templates/#{template_id}.json", options
end | ruby | {
"resource": ""
} |
q25421 | CreateSend.CreateSend.clients | validation | def clients
response = get('/clients.json')
response.map{|item| Hashie::Mash.new(item)}
end | ruby | {
"resource": ""
} |
q25422 | CreateSend.CreateSend.administrators | validation | def administrators
response = get('/admins.json')
response.map{|item| Hashie::Mash.new(item)}
end | ruby | {
"resource": ""
} |
q25423 | CreateSend.CreateSend.set_primary_contact | validation | def set_primary_contact(email)
options = { :query => { :email => email } }
response = put("/primarycontact.json", options)
Hashie::Mash.new(response)
end | ruby | {
"resource": ""
} |
q25424 | CreateSend.List.create_custom_field | validation | def create_custom_field(field_name, data_type, options=[],
visible_in_preference_center=true)
options = { :body => {
:FieldName => field_name,
:DataType => data_type,
:Options => options,
:VisibleInPreferenceCenter => visible_in_preference_center }.to_json }
response = post "customfields", options
response.parsed_response
end | ruby | {
"resource": ""
} |
q25425 | CreateSend.List.update_custom_field | validation | def update_custom_field(custom_field_key, field_name,
visible_in_preference_center)
custom_field_key = CGI.escape(custom_field_key)
options = { :body => {
:FieldName => field_name,
:VisibleInPreferenceCenter => visible_in_preference_center }.to_json }
response = put "customfields/#{custom_field_key}", options
response.parsed_response
end | ruby | {
"resource": ""
} |
q25426 | CreateSend.List.update_custom_field_options | validation | def update_custom_field_options(custom_field_key, new_options,
keep_existing_options)
custom_field_key = CGI.escape(custom_field_key)
options = { :body => {
:Options => new_options,
:KeepExistingOptions => keep_existing_options }.to_json }
put "customfields/#{custom_field_key}/options", options
end | ruby | {
"resource": ""
} |
q25427 | CreateSend.List.custom_fields | validation | def custom_fields
response = get "customfields"
response.map{|item| Hashie::Mash.new(item)}
end | ruby | {
"resource": ""
} |
q25428 | CreateSend.List.segments | validation | def segments
response = get "segments"
response.map{|item| Hashie::Mash.new(item)}
end | ruby | {
"resource": ""
} |
q25429 | CreateSend.List.active | validation | def active(date="", page=1, page_size=1000, order_field="email",
order_direction="asc", include_tracking_preference=false)
paged_result_by_date("active", date, page, page_size, order_field,
order_direction, include_tracking_preference)
end | ruby | {
"resource": ""
} |
q25430 | CreateSend.List.webhooks | validation | def webhooks
response = get "webhooks"
response.map{|item| Hashie::Mash.new(item)}
end | ruby | {
"resource": ""
} |
q25431 | CreateSend.Person.update | validation | def update(new_email_address, name, access_level, password)
options = {
:query => { :email => @email_address },
:body => {
:EmailAddress => new_email_address,
:Name => name,
:AccessLevel => access_level,
:Password => password }.to_json }
put uri_for(client_id), options
# Update @email_address, so this object can continue to be used reliably
@email_address = new_email_address
end | ruby | {
"resource": ""
} |
q25432 | CreateSend.Client.campaigns | validation | def campaigns
response = get 'campaigns'
response.map{|item| Hashie::Mash.new(item)}
end | ruby | {
"resource": ""
} |
q25433 | CreateSend.Client.scheduled | validation | def scheduled
response = get 'scheduled'
response.map{|item| Hashie::Mash.new(item)}
end | ruby | {
"resource": ""
} |
q25434 | CreateSend.Client.drafts | validation | def drafts
response = get 'drafts'
response.map{|item| Hashie::Mash.new(item)}
end | ruby | {
"resource": ""
} |
q25435 | CreateSend.Client.lists | validation | def lists
response = get 'lists'
response.map{|item| Hashie::Mash.new(item)}
end | ruby | {
"resource": ""
} |
q25436 | CreateSend.Client.lists_for_email | validation | def lists_for_email(email_address)
options = { :query => { :email => email_address } }
response = get 'listsforemail', options
response.map{|item| Hashie::Mash.new(item)}
end | ruby | {
"resource": ""
} |
q25437 | CreateSend.Client.people | validation | def people
response = get "people"
response.map{|item| Hashie::Mash.new(item)}
end | ruby | {
"resource": ""
} |
q25438 | CreateSend.Client.suppressionlist | validation | def suppressionlist(page=1, page_size=1000, order_field="email",
order_direction="asc")
options = { :query => {
:page => page,
:pagesize => page_size,
:orderfield => order_field,
:orderdirection => order_direction } }
response = get 'suppressionlist', options
Hashie::Mash.new(response)
end | ruby | {
"resource": ""
} |
q25439 | CreateSend.Client.suppress | validation | def suppress(emails)
options = { :body => {
:EmailAddresses => emails.kind_of?(String) ?
[ emails ] : emails }.to_json }
post "suppress", options
end | ruby | {
"resource": ""
} |
q25440 | CreateSend.Client.templates | validation | def templates
response = get 'templates'
response.map{|item| Hashie::Mash.new(item)}
end | ruby | {
"resource": ""
} |
q25441 | CreateSend.Client.set_basics | validation | def set_basics(company, timezone, country)
options = { :body => {
:CompanyName => company,
:TimeZone => timezone,
:Country => country }.to_json }
put 'setbasics', options
end | ruby | {
"resource": ""
} |
q25442 | CreateSend.Client.set_payg_billing | validation | def set_payg_billing(currency, can_purchase_credits, client_pays,
markup_percentage, markup_on_delivery=0, markup_per_recipient=0,
markup_on_design_spam_test=0)
options = { :body => {
:Currency => currency,
:CanPurchaseCredits => can_purchase_credits,
:ClientPays => client_pays,
:MarkupPercentage => markup_percentage,
:MarkupOnDelivery => markup_on_delivery,
:MarkupPerRecipient => markup_per_recipient,
:MarkupOnDesignSpamTest => markup_on_design_spam_test }.to_json }
put 'setpaygbilling', options
end | ruby | {
"resource": ""
} |
q25443 | CreateSend.Client.set_monthly_billing | validation | def set_monthly_billing(currency, client_pays, markup_percentage,
monthly_scheme = nil)
options = { :body => {
:Currency => currency,
:ClientPays => client_pays,
:MarkupPercentage => markup_percentage,
:MonthlyScheme => monthly_scheme }.to_json }
put 'setmonthlybilling', options
end | ruby | {
"resource": ""
} |
q25444 | CreateSend.Client.transfer_credits | validation | def transfer_credits(credits, can_use_my_credits_when_they_run_out)
options = { :body => {
:Credits => credits,
:CanUseMyCreditsWhenTheyRunOut => can_use_my_credits_when_they_run_out
}.to_json }
response = post 'credits', options
Hashie::Mash.new(response)
end | ruby | {
"resource": ""
} |
q25445 | CreateSend.Campaign.send_preview | validation | def send_preview(recipients, personalize="fallback")
options = { :body => {
:PreviewRecipients => recipients.kind_of?(String) ?
[ recipients ] : recipients,
:Personalize => personalize }.to_json }
post "sendpreview", options
end | ruby | {
"resource": ""
} |
q25446 | CreateSend.Campaign.email_client_usage | validation | def email_client_usage
response = get "emailclientusage", {}
response.map{|item| Hashie::Mash.new(item)}
end | ruby | {
"resource": ""
} |
q25447 | CreateSend.Campaign.opens | validation | def opens(date="", page=1, page_size=1000, order_field="date",
order_direction="asc")
paged_result_by_date("opens", date, page, page_size, order_field,
order_direction)
end | ruby | {
"resource": ""
} |
q25448 | CreateSend.Campaign.clicks | validation | def clicks(date="", page=1, page_size=1000, order_field="date",
order_direction="asc")
paged_result_by_date("clicks", date, page, page_size, order_field,
order_direction)
end | ruby | {
"resource": ""
} |
q25449 | CreateSend.Campaign.unsubscribes | validation | def unsubscribes(date="", page=1, page_size=1000, order_field="date",
order_direction="asc")
paged_result_by_date("unsubscribes", date, page, page_size, order_field,
order_direction)
end | ruby | {
"resource": ""
} |
q25450 | CreateSend.Campaign.spam | validation | def spam(date="", page=1, page_size=1000, order_field="date",
order_direction="asc")
paged_result_by_date("spam", date, page, page_size, order_field,
order_direction)
end | ruby | {
"resource": ""
} |
q25451 | CreateSend.Campaign.bounces | validation | def bounces(date="", page=1, page_size=1000, order_field="date",
order_direction="asc")
paged_result_by_date("bounces", date, page, page_size, order_field,
order_direction)
end | ruby | {
"resource": ""
} |
q25452 | CreateSend.Administrator.update | validation | def update(new_email_address, name)
options = {
:query => { :email => @email_address },
:body => {
:EmailAddress => new_email_address,
:Name => name
}.to_json }
put '/admins.json', options
# Update @email_address, so this object can continue to be used reliably
@email_address = new_email_address
end | ruby | {
"resource": ""
} |
q25453 | SnowplowTracker.AsyncEmitter.flush | validation | def flush(async=true)
loop do
@lock.synchronize do
@queue.synchronize do
@results_unprocessed += 1
end
@queue << @buffer
@buffer = []
end
if not async
LOGGER.info('Starting synchronous flush')
@queue.synchronize do
@all_processed_condition.wait_while { @results_unprocessed > 0 }
LOGGER.info('Finished synchronous flush')
end
end
break if @buffer.size < 1
end
end | ruby | {
"resource": ""
} |
q25454 | RocketChat.Util.stringify_hash_keys | validation | def stringify_hash_keys(hash)
new_hash = {}
hash.each do |key, value|
new_hash[key.to_s] =
if value.is_a? Hash
stringify_hash_keys value
else
value
end
end
new_hash
end | ruby | {
"resource": ""
} |
q25455 | RocketChat.Util.slice_hash | validation | def slice_hash(hash, *keys)
return {} if keys.length.zero?
new_hash = {}
hash.each do |key, value|
new_hash[key] = value if keys.include? key
end
new_hash
end | ruby | {
"resource": ""
} |
q25456 | RocketChat.Server.login | validation | def login(username, password)
response = request_json(
'/api/v1/login',
method: :post,
body: {
username: username,
password: password
}
)
Session.new self, Token.new(response['data'])
end | ruby | {
"resource": ""
} |
q25457 | MandrillDm.Message.attachments | validation | def attachments
regular_attachments = mail.attachments.reject(&:inline?)
regular_attachments.collect do |attachment|
{
name: attachment.filename,
type: attachment.mime_type,
content: Base64.encode64(attachment.body.decoded)
}
end
end | ruby | {
"resource": ""
} |
q25458 | MandrillDm.Message.images | validation | def images
inline_attachments = mail.attachments.select(&:inline?)
inline_attachments.collect do |attachment|
{
name: attachment.cid,
type: attachment.mime_type,
content: Base64.encode64(attachment.body.decoded)
}
end
end | ruby | {
"resource": ""
} |
q25459 | BeanstalkdView.BeanstalkdUtils.get_chart_data_hash | validation | def get_chart_data_hash(tubes)
chart_data = {}
chart_data["total_jobs_data"] = Hash.new
chart_data["buried_jobs_data"] = Hash.new
chart_data["total_jobs_data"]["items"] = Array.new
chart_data["buried_jobs_data"]["items"] = Array.new
tubes.each do |tube|
stats = tube.stats
add_chart_data_to_hash(tube, stats[:total_jobs], chart_data["total_jobs_data"]["items"])
add_chart_data_to_hash(tube, stats[:current_jobs_buried], chart_data["buried_jobs_data"]["items"])
end
chart_data
end | ruby | {
"resource": ""
} |
q25460 | BeanstalkdView.BeanstalkdUtils.guess_min_peek_range | validation | def guess_min_peek_range(tubes)
min = 0
tubes.each do |tube|
response = tube.peek('ready')
if response
if min == 0
min = response.id.to_i
else
min = [min, response.id.to_i].min
end
end
end
# Add some jitter in the opposite direction of 1/4 range
jitter_min = (min-(GUESS_PEEK_RANGE*0.25)).to_i
[1, jitter_min].max
end | ruby | {
"resource": ""
} |
q25461 | Foursquare2.Pages.page_venues | validation | def page_venues(page_id, options={})
response = connection.get do |req|
req.url "pages/#{page_id}/venues", options
end
venues = return_error_or_body(response, response.body.response.venues)
venues = Foursquare2.filter(venues, options[:query]) if options.has_key? :query
venues
end | ruby | {
"resource": ""
} |
q25462 | Foursquare2.Pages.managed_pages | validation | def managed_pages(options={})
response = connection.get do |req|
req.url "pages/managing", options
end
return_error_or_body(response, response.body.response.managing)
end | ruby | {
"resource": ""
} |
q25463 | Foursquare2.Users.search_users_by_tip | validation | def search_users_by_tip(options={})
name = options.delete(:name)
options[:limit] = 500
tips = search_tips(options)
user = []
tips.each do |tip|
user << tip['user'] if check_name(tip['user'], name)
end
user.uniq
end | ruby | {
"resource": ""
} |
q25464 | Foursquare2.Users.user_requests | validation | def user_requests(options={})
response = connection.get do |req|
req.url "users/requests", options
end
return_error_or_body(response, response.body.response.requests)
end | ruby | {
"resource": ""
} |
q25465 | Foursquare2.Users.user_checkins | validation | def user_checkins(options={})
response = connection.get do |req|
req.url "users/self/checkins", options
end
return_error_or_body(response, response.body.response.checkins)
end | ruby | {
"resource": ""
} |
q25466 | Foursquare2.Users.user_friends | validation | def user_friends(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/friends", options
end
return_error_or_body(response, response.body.response.friends)
end | ruby | {
"resource": ""
} |
q25467 | Foursquare2.Users.user_tips | validation | def user_tips(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/tips", options
end
tips = return_error_or_body(response, response.body.response.tips)
tips = Foursquare2.filter(tips, options[:query]) if options.has_key? :query
tips
end | ruby | {
"resource": ""
} |
q25468 | Foursquare2.Users.user_todos | validation | def user_todos(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/todos", options
end
return_error_or_body(response, response.body.response.todos)
end | ruby | {
"resource": ""
} |
q25469 | Foursquare2.Users.user_photos | validation | def user_photos(options={})
response = connection.get do |req|
req.url "users/self/photos", options
end
return_error_or_body(response, response.body.response.photos)
end | ruby | {
"resource": ""
} |
q25470 | Foursquare2.Users.user_venue_history | validation | def user_venue_history(options={})
response = connection.get do |req|
req.url "users/self/venuehistory", options
end
return_error_or_body(response, response.body.response.venues)
end | ruby | {
"resource": ""
} |
q25471 | Foursquare2.Users.user_mayorships | validation | def user_mayorships(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/mayorships", options
end
return_error_or_body(response, response.body.response.mayorships)
end | ruby | {
"resource": ""
} |
q25472 | Foursquare2.Users.user_lists | validation | def user_lists(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/lists", options
end
return_error_or_body(response, response.body.response.lists)
end | ruby | {
"resource": ""
} |
q25473 | Foursquare2.Users.user_friend_request | validation | def user_friend_request(user_id, options={})
response = connection.post do |req|
req.url "users/#{user_id}/request", options
end
return_error_or_body(response, response.body.response)
end | ruby | {
"resource": ""
} |
q25474 | Foursquare2.Users.user_set_friend_pings | validation | def user_set_friend_pings(user_id, value)
response = connection.post do |req|
req.url "users/#{user_id}/setpings", value
end
return_error_or_body(response, response.body.response)
end | ruby | {
"resource": ""
} |
q25475 | Foursquare2.Tips.tip | validation | def tip(tip_id, options={})
response = connection.get do |req|
req.url "tips/#{tip_id}", options
end
return_error_or_body(response, response.body.response.tip)
end | ruby | {
"resource": ""
} |
q25476 | Foursquare2.Tips.search_tips | validation | def search_tips(options={})
response = connection.get do |req|
req.url "tips/search", options
end
return_error_or_body(response, response.body.response.tips)
end | ruby | {
"resource": ""
} |
q25477 | Foursquare2.Tips.venue_tips | validation | def venue_tips(venue_id, options={})
query = options.delete(:query)
response = connection.get do |req|
req.url "venues/#{venue_id}/tips", options
end
tips = return_error_or_body(response, response.body.response.tips)
tips = Foursquare2.filter(tips, query) if query
tips
end | ruby | {
"resource": ""
} |
q25478 | Foursquare2.Tips.add_tip | validation | def add_tip(options={})
response = connection.post do |req|
req.url "tips/add", options
end
return_error_or_body(response, response.body.response.tip)
end | ruby | {
"resource": ""
} |
q25479 | Foursquare2.Tips.mark_tip_todo | validation | def mark_tip_todo(tip_id, options={})
response = connection.post do |req|
req.url "tips/#{tip_id}/marktodo", options
end
return_error_or_body(response, response.body.response)
end | ruby | {
"resource": ""
} |
q25480 | Foursquare2.Events.event | validation | def event(event_id, options={})
response = connection.get do |req|
req.url "events/#{event_id}", options
end
return_error_or_body(response, response.body.response.event)
end | ruby | {
"resource": ""
} |
q25481 | Foursquare2.Campaigns.campaign | validation | def campaign(campaign_id, options={})
response = connection.get do |req|
req.url "campaigns/#{campaign_id}", options
end
return_error_or_body(response, response.body.response.campaign)
end | ruby | {
"resource": ""
} |
q25482 | Foursquare2.Client.connection | validation | def connection
params = {}
params[:client_id] = @client_id if @client_id
params[:client_secret] = @client_secret if @client_secret
params[:oauth_token] = @oauth_token if @oauth_token
params[:v] = @api_version if @api_version
params[:locale] = @locale if @locale
@connection ||= Faraday::Connection.new(:url => api_url, :ssl => @ssl, :params => params, :headers => default_headers) do |builder|
@connection_middleware.each do |middleware|
builder.use *middleware
end
builder.adapter Faraday.default_adapter
end
end | ruby | {
"resource": ""
} |
q25483 | Foursquare2.Client.return_error_or_body | validation | def return_error_or_body(response, response_body)
if response.body['meta'].code == 200
response_body
else
raise Foursquare2::APIError.new(response.body['meta'], response.body['response'])
end
end | ruby | {
"resource": ""
} |
q25484 | Foursquare2.Checkins.checkin | validation | def checkin(checkin_id, options={})
response = connection.get do |req|
req.url "checkins/#{checkin_id}", options
end
return_error_or_body(response, response.body.response.checkin)
end | ruby | {
"resource": ""
} |
q25485 | Foursquare2.Checkins.recent_checkins | validation | def recent_checkins(options={})
response = connection.get do |req|
req.url "checkins/recent", options
end
return_error_or_body(response, response.body.response.recent)
end | ruby | {
"resource": ""
} |
q25486 | Foursquare2.Checkins.add_checkin | validation | def add_checkin(options={})
response = connection.post do |req|
req.url "checkins/add", options
end
return_error_or_body(response, response.body.response.checkin)
end | ruby | {
"resource": ""
} |
q25487 | Foursquare2.Checkins.add_checkin_comment | validation | def add_checkin_comment(checkin_id, options={})
response = connection.post do |req|
req.url "checkins/#{checkin_id}/addcomment", options
end
return_error_or_body(response, response.body.response)
end | ruby | {
"resource": ""
} |
q25488 | Foursquare2.Checkins.add_checkin_reply | validation | def add_checkin_reply(checkin_id, options={})
response = connection.post do |req|
req.url "checkins/#{checkin_id}/reply", options
end
return_error_or_body(response, response.body.response.reply)
end | ruby | {
"resource": ""
} |
q25489 | Foursquare2.Venuegroups.venuegroup | validation | def venuegroup(group_id, options={})
response = connection.get do |req|
req.url "venuegroups/#{group_id}", options
end
return_error_or_body(response, response.body.response.venueGroup)
end | ruby | {
"resource": ""
} |
q25490 | Foursquare2.Venuegroups.add_venuegroup | validation | def add_venuegroup(options={})
response = connection.post do |req|
req.url "venuegroups/add", options
end
return_error_or_body(response, response.body.response.venueGroup)
end | ruby | {
"resource": ""
} |
q25491 | Foursquare2.Venuegroups.venuegroup_update | validation | def venuegroup_update(group_id, options={})
response = connection.post do |req|
req.url "venuegroups/#{group_id}/update", options
end
return_error_or_body(response, response.body.response.venueGroup)
end | ruby | {
"resource": ""
} |
q25492 | Foursquare2.Venuegroups.list_venuegroup | validation | def list_venuegroup(options={})
response = connection.get do |req|
req.url "venuegroups/list", options
end
return_error_or_body(response, response.body.response.venueGroups)
end | ruby | {
"resource": ""
} |
q25493 | Foursquare2.Specials.special | validation | def special(special_id, options={})
response = connection.get do |req|
req.url "specials/#{special_id}", options
end
return_error_or_body(response, response.body.response.special)
end | ruby | {
"resource": ""
} |
q25494 | Foursquare2.Specials.search_specials | validation | def search_specials(options={})
response = connection.get do |req|
req.url "specials/search", options
end
return_error_or_body(response, response.body.response.specials.items)
end | ruby | {
"resource": ""
} |
q25495 | Foursquare2.Lists.list | validation | def list(list_id, options={})
response = connection.get do |req|
req.url "lists/#{list_id}", options
end
return_error_or_body(response, response.body.response.list)
end | ruby | {
"resource": ""
} |
q25496 | Foursquare2.Venues.trending_venues | validation | def trending_venues(ll, options={})
options[:ll] = ll
response = connection.get do |req|
req.url "venues/trending", options
end
return_error_or_body(response, response.body.response)
end | ruby | {
"resource": ""
} |
q25497 | Foursquare2.Venues.search_venues_by_tip | validation | def search_venues_by_tip(options={})
tips = search_tips(options)
venues = []
tips.each do |tip|
venues << tip['venue']
end
venues
end | ruby | {
"resource": ""
} |
q25498 | Foursquare2.Venues.venue_categories | validation | def venue_categories(options={})
response = connection.get do |req|
req.url "venues/categories", options
end
return_error_or_body(response, response.body.response.categories)
end | ruby | {
"resource": ""
} |
q25499 | Foursquare2.Venues.venue_links | validation | def venue_links(venue_id, options={})
response = connection.get do |req|
req.url "venues/#{venue_id}/links", options
end
return_error_or_body(response, response.body.response.links)
end | ruby | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.