Pokemon¶
flowtask.components.Pokemon
¶
Pokemon
¶
Bases: HTTPService, FlowComponent
Pokémon Component
Overview
This component interacts with the Pokémon API to retrieve data about machines or their on-hand inventory.
It supports two main operations determined by the type parameter:
- "machines": Retrieves a list of machines.
- "inventory": Retrieves on-hand inventory data for specified machines.
- sites: Retrieves the Pokemon sites
- ****: Retrieves the Pokemon
- warehouses: Retrieves the Pokemon warehouses
The component handles authentication, constructs the necessary requests, processes the data, and returns a pandas DataFrame suitable for further analysis in your data pipeline.
.. table:: Properties :widths: auto
+----------------------------+----------+----------------------------------------------------------------------------------------------+
| Name | Required | Summary |
+----------------------------+----------+----------------------------------------------------------------------------------------------+
| credentials | Yes | Dictionary containing API credentials: "BASE_URL", "CLIENT_ID", and "CLIENT_SECRET". |
| | | Credentials can be retrieved from environment variables. |
+----------------------------+----------+----------------------------------------------------------------------------------------------+
| type | Yes | Type of operation to perform. Accepts "machines" to retrieve machine data or "inventory" |
| | | to retrieve machine inventory data. |
+----------------------------+----------+----------------------------------------------------------------------------------------------+
| ids | No | List of machine IDs to retrieve inventory for when type is "inventory". |
| | | Overrides IDs from the previous step if provided. |
+----------------------------+----------+----------------------------------------------------------------------------------------------+
| data | No | Data from the previous step, typically a pandas DataFrame containing machine |
| | | IDs in a column named "machine_id". Used when type is "inventory". |
+----------------------------+----------+----------------------------------------------------------------------------------------------+
Returns
This component returns a pandas DataFrame containing the retrieved data from the Pokémon API. The structure of the DataFrame depends on the operation type:
- For
type = "machines": The DataFrame contains information about machines, with columns corresponding to the machine attributes provided by the API. -
For
type = "inventory": The DataFrame contains on-hand inventory details for each machine, includingmachineIdand detailed slot information.Example:
get_machines_inventory_payload
¶
Create payload following API specification
split_chunk_ids
staticmethod
¶
Splits a Series of IDs into chunks of a specified size.
Parameters: items (pd.Series): A pandas Series containing the IDs to be split. chunk_size (int): The maximum number of IDs per chunk.
list: A list of NumPy arrays, each containing a chunk of IDs. If the Series is empty or all IDs are NaN, returns an empty list or a list containing an empty array.