Skip to content

Commit a18d419

Browse files
committed
Added high-level diagrams
1 parent f58c991 commit a18d419

File tree

8 files changed

+351
-0
lines changed

8 files changed

+351
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
```mermaid
2+
graph LR
3+
Session["Session"]
4+
ApiAccess["ApiAccess"]
5+
Session -- "initializes" --> ApiAccess
6+
Session -- "accesses" --> ApiAccess
7+
ApiAccess -- "initializes" --> ApiAccess
8+
ApiAccess -- "stores" --> ApiAccess
9+
ApiAccess -- "validates" --> ApiAccess
10+
```
11+
12+
## Component Details
13+
14+
The Shopify API Access Control subsystem is responsible for managing and validating the scopes required for accessing Shopify resources. It ensures that the application has the necessary permissions to perform specific actions. The `Session` component manages the authentication and authorization state, while the `ApiAccess` component handles the validation of API access scopes. The flow starts with the creation of a `Session`, during which the `ApiAccess` component is initialized and the scopes are validated. This ensures that only authorized requests are allowed to access the Shopify API.
15+
16+
### Session
17+
The `Session` class is responsible for managing the authentication and authorization state for a Shopify shop. It stores information such as the shop's domain, access token, and API version. It handles the retrieval and storage of access tokens, which are essential for making authorized requests to the Shopify API. The session is initialized with the shop domain and access token, and it provides methods for accessing and managing this information.
18+
- **Related Classes/Methods**: `shopify_python_api.shopify.session.Session`
19+
20+
### ApiAccess
21+
The `ApiAccess` class is responsible for managing and validating the access scopes required for interacting with the Shopify API. It stores the available and granted scopes and provides methods for validating if the granted scopes are sufficient for a particular API call. It acts as a gatekeeper, ensuring that only authorized requests are allowed to access the Shopify API. The `ApiAccess` component is initialized during the session creation and validates the scopes against the granted scopes.
22+
- **Related Classes/Methods**: `shopify_python_api.shopify.api_access.ApiAccess`, `shopify_python_api.shopify.api_access.ApiAccess.__init__`, `shopify_python_api.shopify.api_access.ApiAccess.__store_scopes`, `shopify_python_api.shopify.api_access.ApiAccess.__validate_scopes`

.codeboarding/API Rate Limiting.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
```mermaid
2+
graph LR
3+
Limits["Limits"]
4+
response["response"]
5+
credit_left["credit_left"]
6+
credit_maxed["credit_maxed"]
7+
credit_limit["credit_limit"]
8+
credit_used["credit_used"]
9+
Limits -- "stores" --> response
10+
Limits -- "stores" --> credit_left
11+
Limits -- "stores" --> credit_maxed
12+
Limits -- "stores" --> credit_limit
13+
Limits -- "stores" --> credit_used
14+
```
15+
16+
## Component Details
17+
18+
The API Rate Limiting component in the Shopify API Python library provides a mechanism to track and manage API usage, preventing applications from exceeding rate limits imposed by Shopify. The core of this component is the `Limits` class, which parses rate limit information from HTTP response headers and stores the credit usage. This allows developers to check the remaining API credits, determine if the limit has been reached, and adjust their application's behavior accordingly to avoid throttling. The component relies on the HTTP response from Shopify's API to extract rate limit data.
19+
20+
### Limits
21+
The `Limits` class is responsible for storing and updating API rate limit information extracted from Shopify API responses. It parses the HTTP response headers to obtain the credit limit, credits used, and credits remaining. It provides methods to access and check these values, allowing developers to monitor their API usage.
22+
- **Related Classes/Methods**: `shopify_python_api.shopify.limits.Limits`
23+
24+
### response
25+
The `response` attribute within the `Limits` class stores the raw HTTP response object received from the Shopify API. This response object contains the headers that hold the rate limit information, which are then parsed by the `Limits` class.
26+
- **Related Classes/Methods**: `shopify_python_api.shopify.limits.Limits`
27+
28+
### credit_left
29+
The `credit_left` attribute stores the number of API credits remaining. It is updated based on the information extracted from the HTTP response headers. This attribute allows developers to quickly check how many API calls they can make before reaching the limit.
30+
- **Related Classes/Methods**: `shopify_python_api.shopify.limits.Limits`
31+
32+
### credit_maxed
33+
The `credit_maxed` attribute is a boolean flag that indicates whether the API credit limit has been reached. It is determined by comparing the credits used with the credit limit. This flag allows developers to easily determine if they need to pause or adjust their API calls.
34+
- **Related Classes/Methods**: `shopify_python_api.shopify.limits.Limits`
35+
36+
### credit_limit
37+
The `credit_limit` attribute stores the maximum API credit limit allowed. This value is extracted from the HTTP response headers and represents the total number of API calls that can be made within a specific time period.
38+
- **Related Classes/Methods**: `shopify_python_api.shopify.limits.Limits`
39+
40+
### credit_used
41+
The `credit_used` attribute stores the number of API credits that have been used. This value is extracted from the HTTP response headers and represents the number of API calls that have been made.
42+
- **Related Classes/Methods**: `shopify_python_api.shopify.limits.Limits`

.codeboarding/API Versioning.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
```mermaid
2+
graph LR
3+
ApiVersion["ApiVersion"]
4+
coerce_to_version["coerce_to_version"]
5+
define_known_versions["define_known_versions"]
6+
version["version"]
7+
is_unstable["is_unstable"]
8+
ApiVersion -- "Defines and manages" --> define_known_versions
9+
ApiVersion -- "Coerces to a valid" --> coerce_to_version
10+
coerce_to_version -- "Uses defined versions from" --> define_known_versions
11+
ApiVersion -- "Stores the" --> version
12+
ApiVersion -- "Indicates if" --> is_unstable
13+
```
14+
15+
## Component Details
16+
17+
The API Versioning component provides a mechanism for specifying and validating the version of the Shopify API to be used. It defines known API versions, allows for coercion of version strings to ApiVersion objects, and provides a way to determine if a version is unstable. This ensures that the application interacts with the Shopify API in a compatible manner.
18+
19+
### ApiVersion
20+
Represents a specific version of the Shopify API. It encapsulates the version string and provides methods for validation and comparison. It also determines if the version is unstable.
21+
- **Related Classes/Methods**: `shopify_python_api.shopify.api_version.ApiVersion`
22+
23+
### coerce_to_version
24+
A method within the ApiVersion class responsible for converting a version string into a valid ApiVersion object. It validates the input against the defined known versions and raises an exception if the version is invalid.
25+
- **Related Classes/Methods**: `shopify_python_api.shopify.api_version.ApiVersion:coerce_to_version`
26+
27+
### define_known_versions
28+
A method within the ApiVersion class that defines the valid and supported API versions. This method likely initializes a data structure containing the known versions, which is then used by `coerce_to_version` for validation.
29+
- **Related Classes/Methods**: `shopify_python_api.shopify.api_version.ApiVersion:define_known_versions`
30+
31+
### version
32+
A property of the ApiVersion class that stores the actual version string (e.g., '2023-01'). It's the core data representing the API version.
33+
- **Related Classes/Methods**: `shopify_python_api.shopify.api_version.ApiVersion`
34+
35+
### is_unstable
36+
A property of the ApiVersion class that indicates whether the API version is unstable or not.
37+
- **Related Classes/Methods**: `shopify_python_api.shopify.api_version.ApiVersion`
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
```mermaid
2+
graph LR
3+
PaginatedCollection["PaginatedCollection"]
4+
__init__["__init__"]
5+
next_page["next_page"]
6+
previous_page["previous_page"]
7+
__iter__["__iter__"]
8+
PaginatedCollection -- "initializes" --> __init__
9+
PaginatedCollection -- "fetches next page" --> next_page
10+
PaginatedCollection -- "fetches previous page" --> previous_page
11+
PaginatedCollection -- "implements iteration" --> __iter__
12+
```
13+
14+
## Component Details
15+
16+
The `Collection Handling` component provides a mechanism for iterating over paginated collections of Shopify resources. It abstracts the complexity of fetching data from the Shopify API in chunks, allowing developers to easily retrieve large datasets. The core of this component is the `PaginatedCollection` class, which manages the pagination logic and provides methods for navigating through the pages of data. It simplifies the process of retrieving large datasets from the Shopify API by handling the fetching of next and previous pages of results.
17+
18+
### PaginatedCollection
19+
The `PaginatedCollection` class is the central component for handling paginated data from the Shopify API. It stores the current URL, session, and response, and provides methods to navigate through the pages of data. It initializes with a URL and provides methods to navigate through the pages of data.
20+
- **Related Classes/Methods**: `shopify_python_api.shopify.collection.PaginatedCollection`
21+
22+
### __init__
23+
The `__init__` method is the constructor of the `PaginatedCollection` class. It initializes the collection with the initial URL, session, and response obtained from the Shopify API. It sets up the necessary attributes for managing the pagination process.
24+
- **Related Classes/Methods**: `shopify_python_api.shopify.collection.PaginatedCollection.__init__`
25+
26+
### next_page
27+
The `next_page` method fetches the next page of results from the Shopify API, if available. It constructs the next page URL based on the 'next' link in the response headers and makes a request to retrieve the data. It returns a new `PaginatedCollection` instance representing the next page.
28+
- **Related Classes/Methods**: `shopify_python_api.shopify.collection.PaginatedCollection.next_page`
29+
30+
### previous_page
31+
The `previous_page` method fetches the previous page of results from the Shopify API, if available. It constructs the previous page URL based on the 'previous' link in the response headers and makes a request to retrieve the data. It returns a new `PaginatedCollection` instance representing the previous page.
32+
- **Related Classes/Methods**: `shopify_python_api.shopify.collection.PaginatedCollection.previous_page`
33+
34+
### __iter__
35+
The `__iter__` method makes the `PaginatedCollection` iterable, allowing users to loop through the results page by page. It yields the items from the current page and automatically fetches the next page when the current page is exhausted, providing a seamless iteration experience.
36+
- **Related Classes/Methods**: `shopify_python_api.shopify.collection.PaginatedCollection.__iter__`

.codeboarding/GraphQL Client.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
```mermaid
2+
graph LR
3+
GraphQL["GraphQL"]
4+
GraphQL___init__["GraphQL.__init__"]
5+
GraphQL_execute["GraphQL.execute"]
6+
Session["Session"]
7+
GraphQL -- "Initializes with" --> GraphQL___init__
8+
GraphQL -- "Executes query using" --> GraphQL_execute
9+
GraphQL___init__ -- "Uses" --> Session
10+
GraphQL_execute -- "Uses" --> Session
11+
Session -- "Is used by" --> GraphQL___init__
12+
Session -- "Is used by" --> GraphQL_execute
13+
```
14+
15+
## Component Details
16+
17+
The GraphQL Client component provides a way to interact with the Shopify API using GraphQL queries. It encapsulates the logic for executing queries and handling responses, offering a more flexible alternative to the REST API. The client is initialized with a session, which manages authentication and request details. The execute method sends the GraphQL query to the Shopify API and returns the result.
18+
19+
### GraphQL
20+
Represents the GraphQL client. It is responsible for initializing the client with a session and providing the execute method for running GraphQL queries against the Shopify API.
21+
- **Related Classes/Methods**: `shopify_python_api.shopify.resources.graphql.GraphQL`
22+
23+
### GraphQL.__init__
24+
Initializes the GraphQL client with a session object. The session is used for authentication and request management when interacting with the Shopify API.
25+
- **Related Classes/Methods**: `shopify_python_api.shopify.resources.graphql.GraphQL.__init__`
26+
27+
### GraphQL.execute
28+
Executes a GraphQL query against the Shopify API. It takes the query as input and uses the session to send the request and retrieve the response. It handles the communication with the Shopify API endpoint.
29+
- **Related Classes/Methods**: `shopify_python_api.shopify.resources.graphql.GraphQL.execute`
30+
31+
### Session
32+
Represents a session with the Shopify API. It handles authentication, request management, and other session-related tasks. It is used by the GraphQL client to make requests to the API.
33+
- **Related Classes/Methods**: `shopify_python_api.shopify.session.Session`
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
```mermaid
2+
graph LR
3+
ShopifyResource["ShopifyResource"]
4+
MetafieldsMixin["MetafieldsMixin"]
5+
EventsMixin["EventsMixin"]
6+
Customer["Customer"]
7+
Order["Order"]
8+
Product["Product"]
9+
Image["Image"]
10+
Shop["Shop"]
11+
Customer -- "inherits from" --> ShopifyResource
12+
Order -- "inherits from" --> ShopifyResource
13+
Product -- "inherits from" --> ShopifyResource
14+
Image -- "inherits from" --> ShopifyResource
15+
Shop -- "inherits from" --> ShopifyResource
16+
Customer -- "uses" --> MetafieldsMixin
17+
Shop -- "uses" --> MetafieldsMixin
18+
Image -- "uses" --> MetafieldsMixin
19+
Customer -- "uses" --> EventsMixin
20+
Shop -- "uses" --> EventsMixin
21+
```
22+
23+
## Component Details
24+
25+
The Resource Management component in the Shopify API Python library provides a foundation for interacting with various Shopify resources like products, orders, and customers. It defines a base class, `ShopifyResource`, that handles common API operations such as creating, retrieving, updating, and deleting resources. Mixins like `MetafieldsMixin` and `EventsMixin` extend the functionality of resources by adding support for metafields and events, respectively. Concrete resource classes, such as `Customer`, `Order`, and `Product`, inherit from `ShopifyResource` and implement resource-specific logic. This system promotes code reuse and simplifies the process of interacting with the Shopify API.
26+
27+
### ShopifyResource
28+
Base class for all Shopify resources, providing common API interaction methods. It defines the basic CRUD operations and attributes shared across all resources.
29+
- **Related Classes/Methods**: `shopify_python_api.shopify.base.ShopifyResource`, `shopify_python_api.shopify.base.ShopifyResourceMeta`
30+
31+
### MetafieldsMixin
32+
Mixin for managing metafields associated with a resource. It provides methods to retrieve, create, update, and delete metafields for a given resource.
33+
- **Related Classes/Methods**: `shopify_python_api.shopify.mixins.Metafields`
34+
35+
### EventsMixin
36+
Mixin for accessing events associated with a resource. It provides methods to retrieve events related to a specific resource.
37+
- **Related Classes/Methods**: `shopify_python_api.shopify.mixins.Events`
38+
39+
### Customer
40+
Represents a Shopify customer, extending ShopifyResource with customer-specific functionalities. It inherits the basic API operations from ShopifyResource and adds attributes and methods specific to customers.
41+
- **Related Classes/Methods**: `shopify_python_api.shopify.resources.customer.Customer`
42+
43+
### Order
44+
Represents a Shopify order, extending ShopifyResource with order-specific functionalities. It inherits the basic API operations from ShopifyResource and adds attributes and methods specific to orders.
45+
- **Related Classes/Methods**: `shopify_python_api.shopify.resources.order.Order`
46+
47+
### Product
48+
Represents a Shopify product, extending ShopifyResource with product-specific functionalities. It inherits the basic API operations from ShopifyResource and adds attributes and methods specific to products.
49+
- **Related Classes/Methods**: `shopify_python_api.shopify.resources.product.Product`
50+
51+
### Image
52+
Represents a Shopify Image, extending ShopifyResource. It inherits the basic API operations from ShopifyResource and adds attributes and methods specific to images.
53+
- **Related Classes/Methods**: `shopify_python_api.shopify.resources.image.Image`
54+
55+
### Shop
56+
Represents the Shopify shop, extending ShopifyResource. It inherits the basic API operations from ShopifyResource and adds attributes and methods specific to the shop.
57+
- **Related Classes/Methods**: `shopify_python_api.shopify.resources.shop.Shop`

0 commit comments

Comments
 (0)