sorbet/rbi/gems/sawyer@0.9.2.rbi
# typed: true
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `sawyer` gem.
# Please instead update this file by running `bin/tapioca gem sawyer`.
# source://sawyer//lib/sawyer.rb#1
module Sawyer; end
# source://sawyer//lib/sawyer/agent.rb#5
class Sawyer::Agent
# Agents handle making the requests, and passing responses to
# Sawyer::Response.
#
# endpoint - String URI of the API entry point.
# options - Hash of options.
# :allow_undefined_methods - Allow relations to call all the HTTP verbs,
# not just the ones defined.
# :faraday - Optional Faraday::Connection to use.
# :links_parser - Optional parser to parse link relations
# Defaults: Sawyer::LinkParsers::Hal.new
# :serializer - Optional serializer Class. Defaults to
# self.serializer_class.
#
# Yields the Faraday::Connection if a block is given.
#
# @return [Agent] a new instance of Agent
# @yield [@conn]
#
# source://sawyer//lib/sawyer/agent.rb#41
def initialize(endpoint, options = T.unsafe(nil)); end
# Returns the value of attribute allow_undefined_methods.
#
# source://sawyer//lib/sawyer/agent.rb#9
def allow_undefined_methods; end
# Sets the attribute allow_undefined_methods
#
# @param value the value to set the attribute allow_undefined_methods to.
#
# source://sawyer//lib/sawyer/agent.rb#9
def allow_undefined_methods=(_arg0); end
# @return [Boolean]
#
# source://sawyer//lib/sawyer/agent.rb#142
def allow_undefined_methods?; end
# Makes a request through Faraday.
#
# method - The Symbol name of an HTTP method.
# url - The String URL to access. This can be relative to the Agent's
# endpoint.
# data - The Optional Hash or Resource body to be sent. :get or :head
# requests can have no body, so this can be the options Hash
# instead.
# options - Hash of option to configure the API request.
# :headers - Hash of API headers to set.
# :query - Hash of URL query params to set.
#
# Returns a Sawyer::Response.
#
# source://sawyer//lib/sawyer/agent.rb#90
def call(method, url, data = T.unsafe(nil), options = T.unsafe(nil)); end
# Public: Close the underlying connection.
#
# source://sawyer//lib/sawyer/agent.rb#52
def close; end
# Decodes a String response body to a resource.
#
# str - The String body from the response.
#
# Returns an Object resource (Hash by default).
#
# source://sawyer//lib/sawyer/agent.rb#129
def decode_body(str); end
# Encodes an object to a string for the API request.
#
# data - The Hash or Resource that is being sent.
#
# Returns a String.
#
# source://sawyer//lib/sawyer/agent.rb#120
def encode_body(data); end
# source://sawyer//lib/sawyer/agent.rb#137
def expand_url(url, options = T.unsafe(nil)); end
# source://sawyer//lib/sawyer/agent.rb#146
def inspect; end
# Returns the value of attribute links_parser.
#
# source://sawyer//lib/sawyer/agent.rb#8
def links_parser; end
# Sets the attribute links_parser
#
# @param value the value to set the attribute links_parser to.
#
# source://sawyer//lib/sawyer/agent.rb#8
def links_parser=(_arg0); end
# source://sawyer//lib/sawyer/agent.rb#155
def marshal_dump; end
# source://sawyer//lib/sawyer/agent.rb#159
def marshal_load(dumped); end
# source://sawyer//lib/sawyer/agent.rb#133
def parse_links(data); end
# Public: Retains a reference to the root relations of the API.
#
# Returns a Sawyer::Relation::Map.
#
# source://sawyer//lib/sawyer/agent.rb#59
def rels; end
# Public: Retains a reference to the root response of the API.
#
# Returns a Sawyer::Response.
#
# source://sawyer//lib/sawyer/agent.rb#66
def root; end
# Public: Hits the root of the API to get the initial actions.
#
# Returns a Sawyer::Response.
#
# source://sawyer//lib/sawyer/agent.rb#73
def start; end
# private
#
# source://sawyer//lib/sawyer/agent.rb#151
def to_yaml_properties; end
class << self
# source://sawyer//lib/sawyer/agent.rb#23
def decode(data); end
# source://sawyer//lib/sawyer/agent.rb#19
def encode(data); end
# source://sawyer//lib/sawyer/agent.rb#15
def serializer; end
# Sets the attribute serializer
#
# @param value the value to set the attribute serializer to.
#
# source://sawyer//lib/sawyer/agent.rb#12
def serializer=(_arg0); end
end
end
# source://sawyer//lib/sawyer/agent.rb#6
Sawyer::Agent::NO_BODY = T.let(T.unsafe(nil), Set)
# source://sawyer//lib/sawyer.rb#4
class Sawyer::Error < ::StandardError; end
# source://sawyer//lib/sawyer/link_parsers/hal.rb#2
module Sawyer::LinkParsers; end
# source://sawyer//lib/sawyer/link_parsers/hal.rb#4
class Sawyer::LinkParsers::Hal
# source://sawyer//lib/sawyer/link_parsers/hal.rb#6
def parse(data); end
end
# source://sawyer//lib/sawyer/link_parsers/simple.rb#4
class Sawyer::LinkParsers::Simple
# Public: Parses simple *_url style links on resources
#
# data - Hash of resource data
#
# Returns a Hash of data with separate links Hash
#
# source://sawyer//lib/sawyer/link_parsers/simple.rb#14
def parse(data); end
end
# source://sawyer//lib/sawyer/link_parsers/simple.rb#6
Sawyer::LinkParsers::Simple::LINK_REGEX = T.let(T.unsafe(nil), Regexp)
# source://sawyer//lib/sawyer/relation.rb#2
class Sawyer::Relation
# A Relation represents an available next action for a resource.
#
# agent - The Sawyer::Agent that made the request.
# name - The Symbol name of the relation.
# href - The String URL of the location of the next action.
# method - The Symbol HTTP method. Default: :get
#
# @return [Relation] a new instance of Relation
#
# source://sawyer//lib/sawyer/relation.rb#108
def initialize(agent, name, href, method = T.unsafe(nil)); end
# Returns the value of attribute agent.
#
# source://sawyer//lib/sawyer/relation.rb#56
def agent; end
# Returns the value of attribute available_methods.
#
# source://sawyer//lib/sawyer/relation.rb#56
def available_methods; end
# Public: Makes an API request with the curent Relation.
#
# data - The Optional Hash or Resource body to be sent. :get or :head
# requests can have no body, so this can be the options Hash
# instead.
# options - Hash of option to configure the API request.
# :headers - Hash of API headers to set.
# :query - Hash of URL query params to set.
# :method - Symbol HTTP method.
#
# Raises ArgumentError if the :method value is not in @available_methods.
# Returns a Sawyer::Response.
#
# source://sawyer//lib/sawyer/relation.rb#259
def call(data = T.unsafe(nil), options = T.unsafe(nil)); end
# Public: Makes an API request with the curent Relation using DELETE.
#
# data - The Optional Hash or Resource body to be sent.
# options - Hash of option to configure the API request.
# :headers - Hash of API headers to set.
# :query - Hash of URL query params to set.
# :method - Symbol HTTP method.
#
# Returns a Sawyer::Response.
#
# source://sawyer//lib/sawyer/relation.rb#221
def delete(data = T.unsafe(nil), options = T.unsafe(nil)); end
# Public: Makes an API request with the curent Relation using GET.
#
# data - The Optional Hash or Resource body to be sent. :get or :head
# requests can have no body, so this can be the options Hash
# instead.
# options - Hash of option to configure the API request.
# :headers - Hash of API headers to set.
# :query - Hash of URL query params to set.
# :method - Symbol HTTP method.
#
# Returns a Sawyer::Response.
#
# source://sawyer//lib/sawyer/relation.rb#161
def get(options = T.unsafe(nil)); end
# Public: Makes an API request with the curent Relation using HEAD.
#
# data - The Optional Hash or Resource body to be sent. :get or :head
# requests can have no body, so this can be the options Hash
# instead.
# options - Hash of option to configure the API request.
# :headers - Hash of API headers to set.
# :query - Hash of URL query params to set.
# :method - Symbol HTTP method.
#
# Returns a Sawyer::Response.
#
# source://sawyer//lib/sawyer/relation.rb#144
def head(options = T.unsafe(nil)); end
# source://octokit/6.0.0/lib/ext/sawyer/relation.rb#6
def href(options = T.unsafe(nil)); end
# Returns the value of attribute href_template.
#
# source://sawyer//lib/sawyer/relation.rb#56
def href_template; end
# source://sawyer//lib/sawyer/relation.rb#268
def inspect; end
# Returns the value of attribute method.
#
# source://sawyer//lib/sawyer/relation.rb#56
def method; end
# Returns the value of attribute name.
#
# source://sawyer//lib/sawyer/relation.rb#56
def name; end
# Public: Makes an API request with the curent Relation using OPTIONS.
#
# data - The Optional Hash or Resource body to be sent.
# options - Hash of option to configure the API request.
# :headers - Hash of API headers to set.
# :query - Hash of URL query params to set.
# :method - Symbol HTTP method.
#
# Returns a Sawyer::Response.
#
# source://sawyer//lib/sawyer/relation.rb#236
def options(data = T.unsafe(nil), opt = T.unsafe(nil)); end
# Public: Makes an API request with the curent Relation using PATCH.
#
# data - The Optional Hash or Resource body to be sent.
# options - Hash of option to configure the API request.
# :headers - Hash of API headers to set.
# :query - Hash of URL query params to set.
# :method - Symbol HTTP method.
#
# Returns a Sawyer::Response.
#
# source://sawyer//lib/sawyer/relation.rb#206
def patch(data = T.unsafe(nil), options = T.unsafe(nil)); end
# Public: Makes an API request with the curent Relation using POST.
#
# data - The Optional Hash or Resource body to be sent.
# options - Hash of option to configure the API request.
# :headers - Hash of API headers to set.
# :query - Hash of URL query params to set.
# :method - Symbol HTTP method.
#
# Returns a Sawyer::Response.
#
# source://sawyer//lib/sawyer/relation.rb#176
def post(data = T.unsafe(nil), options = T.unsafe(nil)); end
# Public: Makes an API request with the curent Relation using PUT.
#
# data - The Optional Hash or Resource body to be sent.
# options - Hash of option to configure the API request.
# :headers - Hash of API headers to set.
# :query - Hash of URL query params to set.
# :method - Symbol HTTP method.
#
# Returns a Sawyer::Response.
#
# source://sawyer//lib/sawyer/relation.rb#191
def put(data = T.unsafe(nil), options = T.unsafe(nil)); end
class << self
# Public: Builds a single Relation from the given options. These are
# usually taken from a `_links` property in a resource.
#
# agent - The Sawyer::Agent that made the request.
# name - The Symbol name of the Relation.
# options - A Hash containing the other Relation properties.
# :href - The String URL of the next action's location.
# :method - The optional String HTTP method.
#
# Returns a Relation.
#
# source://sawyer//lib/sawyer/relation.rb#93
def from_link(agent, name, options); end
# Public: Builds an index of Relations from the value of a `_links`
# property in a resource. :get is the default method. Any links with
# multiple specified methods will get multiple relations created.
#
# index - The Hash mapping Relation names to the Hash Relation
# options.
# rels - A Relation::Map to store the Relations.
#
# Returns a Relation::Map
#
# source://sawyer//lib/sawyer/relation.rb#71
def from_links(agent, index, rels = T.unsafe(nil)); end
end
end
# source://sawyer//lib/sawyer/relation.rb#3
class Sawyer::Relation::Map
# Tracks the available next actions for a resource, and
# issues requests for them.
#
# @return [Map] a new instance of Map
#
# source://sawyer//lib/sawyer/relation.rb#6
def initialize; end
# Adds a Relation to the map.
#
# rel - A Relation.
#
# Returns nothing.
#
# source://sawyer//lib/sawyer/relation.rb#15
def <<(rel); end
# Gets the raw Relation by its name.
#
# key - The Symbol name of the Relation.
#
# Returns a Relation.
#
# source://sawyer//lib/sawyer/relation.rb#24
def [](key); end
# source://sawyer//lib/sawyer/relation.rb#50
def inspect; end
# Gets a list of the Relation names.
#
# Returns an Array of Symbols in no specific order.
#
# source://sawyer//lib/sawyer/relation.rb#38
def keys; end
# Gets the number of mapped Relations.
#
# Returns an Integer.
#
# source://sawyer//lib/sawyer/relation.rb#31
def size; end
# source://sawyer//lib/sawyer/relation.rb#42
def to_h; end
# source://sawyer//lib/sawyer/relation.rb#42
def to_hash; end
end
# source://sawyer//lib/sawyer/resource.rb#4
class Sawyer::Resource
include ::Enumerable
extend ::Forwardable
# Initializes a Resource with the given data.
#
# agent - The Sawyer::Agent that made the API request.
# data - Hash of key/value properties.
#
# @return [Resource] a new instance of Resource
#
# source://sawyer//lib/sawyer/resource.rb#15
def initialize(agent, data = T.unsafe(nil)); end
# Allow fields to be retrieved via Hash notation
#
# method - key name
#
# Returns the value from attrs if exists
#
# source://sawyer//lib/sawyer/resource.rb#57
def [](method); end
# Allow fields to be set via Hash notation
#
# method - key name
# value - value to set for the attr key
#
# Returns - value
#
# source://sawyer//lib/sawyer/resource.rb#69
def []=(method, value); end
# Returns the value of attribute _agent.
#
# source://sawyer//lib/sawyer/resource.rb#6
def _agent; end
# Returns the value of attribute _fields.
#
# source://sawyer//lib/sawyer/resource.rb#6
def _fields; end
# Returns the value of attribute _rels.
#
# source://sawyer//lib/sawyer/resource.rb#6
def _rels; end
# Returns the value of attribute attrs.
#
# source://sawyer//lib/sawyer/resource.rb#7
def attrs; end
# source://forwardable/1.3.1/forwardable.rb#226
def dig(*args, &block); end
# source://sawyer//lib/sawyer/resource.rb#127
def each(&block); end
# source://forwardable/1.3.1/forwardable.rb#226
def fetch(*args, &block); end
# source://sawyer//lib/sawyer/resource.rb#123
def inspect; end
# Checks to see if the given key is in this resource.
#
# key - A Symbol key.
#
# Returns true if the key exists, or false.
#
# @return [Boolean]
#
# source://sawyer//lib/sawyer/resource.rb#48
def key?(key); end
# source://sawyer//lib/sawyer/resource.rb#151
def marshal_dump; end
# source://sawyer//lib/sawyer/resource.rb#155
def marshal_load(dumped); end
# Provides access to a resource's attributes.
#
# source://sawyer//lib/sawyer/resource.rb#81
def method_missing(method, *args); end
# Processes an individual value of this resource. Hashes get exploded
# into another Resource, and Arrays get their values processed too.
#
# value - An Object value of a Resource's data.
#
# Returns an Object to set as the value of a Resource key.
#
# source://sawyer//lib/sawyer/resource.rb#35
def process_value(value); end
# source://sawyer//lib/sawyer/resource.rb#136
def to_attrs; end
# source://sawyer//lib/sawyer/resource.rb#136
def to_h; end
# source://sawyer//lib/sawyer/resource.rb#136
def to_hash; end
# private
#
# source://sawyer//lib/sawyer/resource.rb#132
def to_yaml_properties; end
class << self
# Wire up accessor methods to pull from attrs
#
# source://sawyer//lib/sawyer/resource.rb#105
def attr_accessor(*attrs); end
end
end
# source://sawyer//lib/sawyer/resource.rb#78
Sawyer::Resource::ATTR_PREDICATE = T.let(T.unsafe(nil), String)
# source://sawyer//lib/sawyer/resource.rb#77
Sawyer::Resource::ATTR_SETTER = T.let(T.unsafe(nil), String)
# source://sawyer//lib/sawyer/resource.rb#5
Sawyer::Resource::SPECIAL_METHODS = T.let(T.unsafe(nil), Set)
# source://sawyer//lib/sawyer/response.rb#2
class Sawyer::Response
# Builds a Response after a completed request.
#
# agent - The Sawyer::Agent that is managing the API connection.
# res - A Faraday::Response.
#
# @return [Response] a new instance of Response
#
# source://sawyer//lib/sawyer/response.rb#14
def initialize(agent, res, options = T.unsafe(nil)); end
# Returns the value of attribute agent.
#
# source://sawyer//lib/sawyer/response.rb#3
def agent; end
# Returns the value of attribute body.
#
# source://sawyer//lib/sawyer/response.rb#3
def body; end
# source://sawyer//lib/sawyer/response.rb#25
def data; end
# Returns the value of attribute env.
#
# source://sawyer//lib/sawyer/response.rb#3
def env; end
# Returns the value of attribute headers.
#
# source://sawyer//lib/sawyer/response.rb#3
def headers; end
# source://sawyer//lib/sawyer/response.rb#68
def inspect; end
# Turns parsed contents from an API response into a Resource or
# collection of Resources.
#
# data - Either an Array or Hash parsed from JSON.
#
# Returns either a Resource or Array of Resources.
#
# source://sawyer//lib/sawyer/response.rb#38
def process_data(data); end
# Finds link relations from 'Link' response header
#
# Returns an array of Relations
#
# source://sawyer//lib/sawyer/response.rb#50
def process_rels; end
# Returns the value of attribute rels.
#
# source://sawyer//lib/sawyer/response.rb#3
def rels; end
# Returns the value of attribute status.
#
# source://sawyer//lib/sawyer/response.rb#3
def status; end
# source://sawyer//lib/sawyer/response.rb#64
def time; end
# source://sawyer//lib/sawyer/response.rb#60
def timing; end
end
# source://sawyer//lib/sawyer/serializer.rb#5
class Sawyer::Serializer
# Public: Wraps a serialization format for Sawyer. Nested objects are
# prepared for serialization (such as changing Times to ISO 8601 Strings).
# Any serialization format that responds to #dump and #load will work.
#
# @return [Serializer] a new instance of Serializer
#
# source://sawyer//lib/sawyer/serializer.rb#39
def initialize(format, dump_method_name = T.unsafe(nil), load_method_name = T.unsafe(nil)); end
# Public: Decodes a String into an Object (usually a Hash or Array of
# Hashes).
#
# data - An encoded String.
#
# Returns a decoded Object.
#
# source://sawyer//lib/sawyer/serializer.rb#62
def decode(data); end
# source://sawyer//lib/sawyer/serializer.rb#96
def decode_hash(hash); end
# source://sawyer//lib/sawyer/serializer.rb#103
def decode_hash_value(key, value); end
# source://sawyer//lib/sawyer/serializer.rb#88
def decode_object(data); end
# Public: Encodes an Object (usually a Hash or Array of Hashes).
#
# data - Object to be encoded.
#
# Returns an encoded String.
#
# source://sawyer//lib/sawyer/serializer.rb#50
def dump(data); end
# Public: Encodes an Object (usually a Hash or Array of Hashes).
#
# data - Object to be encoded.
#
# Returns an encoded String.
#
# source://sawyer//lib/sawyer/serializer.rb#50
def encode(data); end
# source://sawyer//lib/sawyer/serializer.rb#77
def encode_hash(hash); end
# source://sawyer//lib/sawyer/serializer.rb#69
def encode_object(data); end
# Public: Decodes a String into an Object (usually a Hash or Array of
# Hashes).
#
# data - An encoded String.
#
# Returns a decoded Object.
#
# source://sawyer//lib/sawyer/serializer.rb#62
def load(data); end
# @return [Boolean]
#
# source://sawyer//lib/sawyer/serializer.rb#125
def time_field?(key, value); end
class << self
# source://sawyer//lib/sawyer/serializer.rb#6
def any_json; end
# source://sawyer//lib/sawyer/serializer.rb#18
def json; end
# source://sawyer//lib/sawyer/serializer.rb#30
def message_pack; end
# source://sawyer//lib/sawyer/serializer.rb#24
def multi_json; end
# source://sawyer//lib/sawyer/serializer.rb#12
def yajl; end
end
end
# source://sawyer//lib/sawyer.rb#2
Sawyer::VERSION = T.let(T.unsafe(nil), String)