Class: MediaWiktory::Wikipedia::Api
- Inherits:
-
Object
- Object
- MediaWiktory::Wikipedia::Api
- Includes:
- Actions
- Defined in:
- lib/mediawiktory/wikipedia/api.rb
Overview
Base API class for Wikipedia.
Example of usage:
# For Wikipedia
api = MediaWiktory::Wikipedia::Api.new
api.some_action.some_param(value).other_param(*more_values).perform
# => returns raw response of MediaWiki API
api.some_action.some_param(value).other_param(*more_values).response
# => returns an instance of Response, parsed from JSON
# For any other site:
api = MediaWiktory::Wikipedia::Api.new('https://some.site/w/api.php')
# ...the same as above
Actions module lists all available API actions and refers to corresponding classes and their options.
See also Response for working with return values and MediaWiktory::Wikipedia::Actions::Base for working with actions.
Instance Method Summary collapse
-
#initialize(url = 'https://en.wikipedia.org/w/api.php', **defaults) ⇒ Api
constructor
A new instance of Api.
- #inspect ⇒ Object
Methods included from Actions
#abusefiltercheckmatch, #abusefilterchecksyntax, #abusefilterevalexpression, #abusefilterunblockautopromote, #addstudents, #antispoof, #block, #bouncehandler, #categorytree, #centralauthtoken, #centralnoticechoicedata, #centralnoticequerycampaign, #changeauthenticationdata, #checktoken, #cirrus_config_dump, #cirrus_mapping_dump, #cirrus_settings_dump, #clearhasmsg, #clientlogin, #compare, #createaccount, #cspreport, #cxconfiguration, #cxdelete, #cxpublish, #cxsave, #cxsuggestionlist, #cxtoken, #delete, #deleteeducation, #deleteglobalaccount, #echomarkread, #echomarkseen, #edit, #editmassmessagelist, #emailuser, #enlist, #expandtemplates, #fancycaptchareload, #featuredfeed, #feedcontributions, #feedrecentchanges, #feedwatchlist, #filerevert, #flagconfig, #globalblock, #globaluserrights, #graph, #help, #imagerotate, #import, #jsonconfig, #jsondata, #languagesearch, #linkaccount, #liststudents, #login, #logout, #managetags, #massmessage, #mergehistory, #mobileview, #move, #oathvalidate, #opensearch, #options, #pagetriageaction, #pagetriagelist, #pagetriagestats, #pagetriagetagging, #pagetriagetemplate, #paraminfo, #parse, #parsoid_batch, #patrol, #protect, #purge, #query, #refresheducation, #removeauthenticationdata, #resetpassword, #review, #reviewactivity, #revisiondelete, #rollback, #rsd, #sanitize_mapdata, #scribunto_console, #setglobalaccountstatus, #setnotificationtimestamp, #setpagelanguage, #shortenurl, #sitematrix, #spamblacklist, #stabilize, #stashedit, #strikevote, #tag, #templatedata, #thank, #titleblacklist, #tokens, #transcodereset, #ulslocalization, #unblock, #undelete, #unlinkaccount, #upload, #userrights, #validatepassword, #visualeditor, #visualeditoredit, #watch, #webapp_manifest, #wikilove, #zeroconfig
Constructor Details
#initialize(url = 'https://en.wikipedia.org/w/api.php', **defaults) ⇒ Api
Returns a new instance of Api.
69 70 71 72 |
# File 'lib/mediawiktory/wikipedia/api.rb', line 69 def initialize(url = 'https://en.wikipedia.org/w/api.php', **defaults) , @defaults = defaults.partition { |k, _| CLIENT_OPTIONS.include?(k) }.map(&:to_h) @client = Client.new(url, **) end |
Instance Method Details
#inspect ⇒ Object
74 75 76 |
# File 'lib/mediawiktory/wikipedia/api.rb', line 74 def inspect "#<#{self.class.name}(#{@client.url})>" end |