Getting Started with Youtube

Getting Started

Install the Package

Install the gem from the command line:

gem install My-first-api-matic -v 1.0

Or add the gem to your Gemfile and run bundle:

gem 'My-first-api-matic', '1.0'

For additional gem details, see the RubyGems page for the My-first-api-matic gem.

Initialize the API Client

The following parameters are configurable for the API Client:

Parameter Type Description
timeout Float The value to use for connection timeout.
Default: 60
max_retries Integer The number of times to retry an endpoint call if it fails.
Default: 0
retry_interval Float Pause in seconds between retries.
Default: 1
backoff_factor Float The amount to multiply each successive retry's interval amount by in order to provide backoff.
Default: 2
retry_statuses Array A list of HTTP statuses to retry.
Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]
retry_methods Array A list of HTTP methods to retry.
Default: %i[get put]

The API client can be initialized as follows:

client = Youtube::Client.new(
)

API Errors

Here is the list of errors that the API might throw.

HTTP Status Code Error Description Exception Class
401 dfgdfgdfgdfgdsfg ProblemDetailsException

Client Class Documentation

Youtube Client

The gateway for the SDK. This class acts as a factory for the Controllers and also holds the configuration of the SDK.

Controllers

Name Description
api Gets APIController

API Reference

List of APIs

API

Overview

Get instance

An instance of the APIController class can be accessed from the API Client.

client_controller = client.client

Get Forcast

get list of 5 random forcasts

:information_source: Note This endpoint does not require authentication.

def get_forcast(param: 'String.Empty')
Parameters
Parameter Type Tags Description
param String Query, Optional default string parameter
Default: 'String.Empty'
Server

Server::DEFAULT

Response Type

Mixed

Example Usage
param = 'my value for error'
result = client_controller.get_forcast(param: param)
Example Response
[
  {
    "date": "2021-05-27T10:33:06.7728939+05:00",
    "temperatureC": -7,
    "temperatureF": 20,
    "summary": "Scorching"
  },
  {
    "date": "2021-05-28T10:33:06.7729006+05:00",
    "temperatureC": 6,
    "temperatureF": 42,
    "summary": "Bracing"
  }
]
Errors
HTTP Status Code Error Description Exception Class
400 Test error message ProblemDetailsException
404 not found APIException

Model Reference

Structures

Weather Forecast

Class Name

WeatherForecast

Fields
Name Type Tags Description
date DateTime Required The time when forecast was taken
temperature_c Integer Required the value of temperature in Centigrade
temperature_f Integer Required, Constant the value of temperature in Fahrenheit
summary String Required, Constant -
Example (as JSON)
{
  "date": "2021-05-27T10:33:06.7728939+05:00",
  "temperatureC": -7,
  "temperatureF": 20,
  "summary": "Scorching"
}

Weather Forcase Json Imported

Class Name

WeatherForcaseJsonImported

Fields
Name Type Tags Description
date String Required -
temperature_c Integer Required -
temperature_f Integer Required -
summary String Required -
Example (as JSON)
{
  "date": "2021-05-27T10:33:06.7728939+05:00",
  "temperatureC": -7,
  "temperatureF": 20,
  "summary": "Scorching"
}

Field Parameter Validator

Class Name

FieldParameterValidator

Fields
Name Type Tags Description
precision Float Required Constraints: > 0, < 600, Multiple Of: 10, Total Digits: 1000, Fraction Digits: 2
string Array<String> Optional, Constant Constraints: Minimum Items: 5, Maximum Items: 200, Minimum Length: 3, Maximum Length: 10, Pattern: /^[A-Z]+$/i
unix_format_date_time DateTime Required -
object Object Required -
int_64 Long Required Constraints: > 23, < 23, Multiple Of: 3, Total Digits: 23, Fraction Digits: 23, Pattern: 2
Example (as JSON)
{
  "Precision": 229.08,
  "UnixFormatDateTime": 1480809600,
  "Object": {
    "key1": "val1",
    "key2": "val2"
  },
  "Int64": 10
}

Enumerations

Test Enum

This is the test description of enum00

Class Name

TestEnum

Fields
Name Description
FIRSTFILED Test description of first filed
SECONDFIELD Test description of Second filed
THIRD_VALUE

Exceptions

Problem Details

Class Name

ProblemDetailsException

Fields
Name Type Tags Description
type String Required, Constant -
title String Required, Constant -
status Integer Required, Constant -
trace_id String Required, Constant -
Example (as JSON)
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "Bad Request",
  "status": 400,
  "traceId": "00-3dd0a6221d0ccd48ad5eb89a9cf3df71-91763b2e58fa4742-00"
}

Utility Classes Documentation

ApiHelper Class

API utility class.

Methods

Name Return Type Description
json_deserialize Hash Deserializes a JSON string to a Ruby Hash.
rfc3339 DateTime Safely converts a string into an RFC3339 DateTime object.

Common Code Documentation

HttpResponse

Http response received.

Properties

Name Type Description
status_code Integer The status code returned by the server.
reason_phrase String The reason phrase returned by the server.
headers Hash Response headers.
raw_body String Response body.
request HttpRequest The request that resulted in this response.

HttpRequest

Represents a single Http Request.

Properties

Name Type Tag Description
http_method HttpMethodEnum The HTTP method of the request.
query_url String The endpoint URL for the API request.
headers Hash Optional Request headers.
parameters Hash Optional Request body.