Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions .codeboarding/API_Resource_Abstraction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
```mermaid
graph LR
PinterestBaseModel["PinterestBaseModel"]
Resource_Data_Models["Resource Data Models"]
Resource_API_Managers["Resource API Managers"]
Pinterest_API_Client_Generated_["Pinterest API Client (Generated)"]
Resource_Data_Models -- "Inherits from" --> PinterestBaseModel
Resource_API_Managers -- "Uses" --> Resource_Data_Models
Resource_API_Managers -- "Interacts with" --> Pinterest_API_Client_Generated_
Pinterest_API_Client_Generated_ -- "Provides services to" --> Resource_API_Managers
```



[![CodeBoarding](https://img.shields.io/badge/Generated%20by-CodeBoarding-9cf?style=flat-square)](https://github.com/CodeBoarding/GeneratedOnBoardings)[![Demo](https://img.shields.io/badge/Try%20our-Demo-blue?style=flat-square)](https://www.codeboarding.org/demo)[![Contact](https://img.shields.io/badge/Contact%20us%20-%20contact@codeboarding.org-lightgrey?style=flat-square)](mailto:contact@codeboarding.org)



## Details



One paragraph explaining the functionality which is represented by this graph. What the main flow is and what is its purpose.



### PinterestBaseModel

The foundational base class for all data models representing Pinterest API resources. It provides common functionalities like serialization, deserialization, and consistent attribute handling, ensuring a uniform structure for all API response and request bodies.





**Related Classes/Methods**:



- <a href="https://github.com/pinterest/pinterest-python-sdk/blob/main/pinterest/utils/base_model.py#L1-L1" target="_blank" rel="noopener noreferrer">`pinterest.utils.base_model.PinterestBaseModel` (1:1)</a>





### Resource Data Models

Concrete implementations of `PinterestBaseModel` for specific API entities (e.g., `AdAccount`, `Pin`, `Campaign`). These classes define the specific attributes and types for each resource, inheriting the base functionalities from `PinterestBaseModel`. They serve as Data Transfer Objects (DTOs) for API interactions.





**Related Classes/Methods**:



- <a href="https://github.com/pinterest/pinterest-python-sdk/blob/main/pinterest/ads/ad_accounts.py#L1-L1" target="_blank" rel="noopener noreferrer">`pinterest.ads.ad_accounts.AdAccount` (1:1)</a>

- <a href="https://github.com/pinterest/pinterest-python-sdk/blob/main/pinterest/organic/pins.py#L1-L1" target="_blank" rel="noopener noreferrer">`pinterest.organic.pins.Pin` (1:1)</a>





### Resource API Managers

Classes responsible for encapsulating the CRUD (Create, Read, Update, Delete/List) operations for specific Pinterest API resources. They provide a high-level, developer-friendly interface, abstracting the direct interaction with the low-level generated API client and handling the mapping of request/response data to `Resource Data Models`. In this architecture, the `Resource Data Models` themselves often contain the API manager functionalities.





**Related Classes/Methods**:



- <a href="https://github.com/pinterest/pinterest-python-sdk/blob/main/pinterest/ads/ad_accounts.py#L1-L1" target="_blank" rel="noopener noreferrer">`pinterest.ads.ad_accounts.AdAccount` (1:1)</a>

- <a href="https://github.com/pinterest/pinterest-python-sdk/blob/main/pinterest/organic/pins.py#L1-L1" target="_blank" rel="noopener noreferrer">`pinterest.organic.pins.Pin` (1:1)</a>





### Pinterest API Client (Generated)

The underlying, auto-generated client library that handles the direct HTTP communication with the Pinterest API endpoints. This component is typically generated from an OpenAPI specification and provides low-level methods for making API calls. The `Resource API Managers` interact with this client to execute API requests.





**Related Classes/Methods**:



- `pinterest_generated_client` (1:1)









### [FAQ](https://github.com/CodeBoarding/GeneratedOnBoardings/tree/main?tab=readme-ov-file#faq)
93 changes: 93 additions & 0 deletions .codeboarding/Pagination_Utility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
```mermaid

graph LR

Bookmark["Bookmark"]

PinterestSDKClient["PinterestSDKClient"]

PinterestBaseModel["PinterestBaseModel"]

PinterestSDKClient -- "returns" --> Bookmark

Bookmark -- "uses" --> PinterestSDKClient

Bookmark -- "invokes methods on" --> PinterestBaseModel

```



[![CodeBoarding](https://img.shields.io/badge/Generated%20by-CodeBoarding-9cf?style=flat-square)](https://github.com/CodeBoarding/GeneratedOnBoardings)[![Demo](https://img.shields.io/badge/Try%20our-Demo-blue?style=flat-square)](https://www.codeboarding.org/demo)[![Contact](https://img.shields.io/badge/Contact%20us%20-%20contact@codeboarding.org-lightgrey?style=flat-square)](mailto:contact@codeboarding.org)



## Details



The `Pagination Utility` component, primarily embodied by the `Bookmark` class, is crucial for handling paginated API responses within the Pinterest Python SDK. It abstracts away the complexities of managing pagination tokens, allowing users to seamlessly iterate through large datasets.



### Bookmark

This is the core component of the pagination utility. It encapsulates the state and logic required to fetch subsequent pages of data from paginated API endpoints. It stores the `bookmark_token` (the pagination cursor), a reference to the `model` (the SDK model instance on which the paginated function was initially called), the `model_fn` (the name of the method on the `model` that retrieves paginated data), and `model_fn_args` (the arguments to be passed to `model_fn`). It uses the `PinterestSDKClient` to execute the actual API calls for fetching the next page.





**Related Classes/Methods**:



- <a href="https://github.com/pinterest/pinterest-python-sdk/blob/main/pinterest/utils/bookmark.py" target="_blank" rel="noopener noreferrer">`Bookmark`</a>

- <a href="https://github.com/pinterest/pinterest-python-sdk/blob/main/pinterest/utils/bookmark.py" target="_blank" rel="noopener noreferrer">`Bookmark:get_next`</a>





### PinterestSDKClient

This is the main client responsible for all interactions with the Pinterest API. The `Bookmark` component holds a reference to an instance of `PinterestSDKClient` and uses it to make the underlying HTTP requests when `get_next()` is invoked. This ensures that all API calls, including those for pagination, are routed through the central client, adhering to authentication and configuration settings.





**Related Classes/Methods**:



- `PinterestSDKClient`





### PinterestBaseModel

This represents the base class for various data models within the SDK (e.g., models for Ads, Organic content). When a paginated list operation is performed on an SDK model (which internally uses the `PinterestSDKClient`), an instance of that model (or the class itself) is passed to the `Bookmark` object along with the method name (`model_fn`). The `Bookmark` then uses this `model` and `model_fn` to dynamically call the appropriate method to retrieve the next page of results.





**Related Classes/Methods**:



- `PinterestBaseModel`









### [FAQ](https://github.com/CodeBoarding/GeneratedOnBoardings/tree/main?tab=readme-ov-file#faq)
Loading