You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for considering contributing to pywa! We appreciate your time and effort in helping improve this project. This guide will walk you through the steps and standards to follow for contributing.
4
+
Thank you for considering contributing to pywa! We appreciate your time and effort in helping improve this project. This
5
+
guide will walk you through the steps and standards to follow for contributing.
5
6
6
7
## Prerequisites
8
+
7
9
-[Python](https://www.python.org/downloads/) 3.10 or higher
8
10
- A [GitHub account](https://github.com)
9
11
- Familiarity with [git](https://git-scm.com/) for version control
@@ -15,7 +17,7 @@ Thank you for considering contributing to pywa! We appreciate your time and effo
- GitHub [Issues](https://github.com/david-lev/pywa/issues) for bug reports and feature requests.
106
+
- GitHub [Discussions](https://github.com/david-lev/pywa/discussions) for general questions, ideas, and showcase.
95
107
96
108
## License
97
109
98
-
By contributing to pywa, you agree that your contributions will be licensed under the MIT License. See the [LICENSE](https://github.com/david-lev/pywa/blob/master/LICENSE) file for details.
110
+
By contributing to pywa, you agree that your contributions will be licensed under the MIT License. See
111
+
the [LICENSE](https://github.com/david-lev/pywa/blob/master/LICENSE) file for details.
99
112
100
113
## Project Structure
101
114
115
+
This project provides both synchronous (`pywa`) and asynchronous (`pywa_async`) implementations. The asynchronous
116
+
implementation structure mirrors the synchronous implementation structure.
117
+
118
+
### Synchronous Structure (`pywa`)
119
+
102
120
```bash
103
121
pywa/
104
122
├── __init__.py
123
+
├── __main__.py
124
+
├── _helpers.py
125
+
├── api.py
126
+
├── cli.py
127
+
├── client.py
128
+
├── errors.py
129
+
├── filters.py
130
+
├── handlers.py
131
+
├── listeners.py
132
+
├── server.py
133
+
├── types/
134
+
│ ├── __init__.py
135
+
│ ├── base_update.py
136
+
│ ├── account_update.py
137
+
│ ├── callback.py
138
+
│ ├── calls.py
139
+
│ ├── chat.py
140
+
│ ├── flows.py
141
+
│ ├── groups.py
142
+
│ ├── media.py
143
+
│ ├── message.py
144
+
│ ├── message_status.py
145
+
│ ├── others.py
146
+
│ ├── sent_update.py
147
+
│ ├── system.py
148
+
│ ├── templates.py
149
+
│ ├── user.py
150
+
│ └── user_preferences.py
151
+
└── utils.py
152
+
```
153
+
154
+
### Asynchronous Structure (`pywa_async`)
155
+
156
+
```bash
157
+
pywa_async/
158
+
├── __init__.py
105
159
├── _helpers.py
106
160
├── api.py
107
161
├── client.py
@@ -110,59 +164,96 @@ pywa/
110
164
├── handlers.py
111
165
├── listeners.py
112
166
├── server.py
113
-
├── types
114
-
│ ├── __init__.py
115
-
│ ├── base_update.py
116
-
│ ├── callback.py
117
-
│ ├── chat_opened.py
118
-
│ ├── flows.py
119
-
│ ├── media.py
120
-
│ ├── message.py
121
-
│ ├── message_status.py
122
-
│ ├── others.py
123
-
│ ├── sent_message.py
124
-
│ └── templates.py
167
+
├── types/
168
+
│ ├── __init__.py
169
+
│ ├── base_update.py
170
+
│ ├── account_update.py
171
+
│ ├── callback.py
172
+
│ ├── calls.py
173
+
│ ├── chat.py
174
+
│ ├── flows.py
175
+
│ ├── groups.py
176
+
│ ├── media.py
177
+
│ ├── message.py
178
+
│ ├── message_status.py
179
+
│ ├── others.py
180
+
│ ├── sent_update.py
181
+
│ ├── system.py
182
+
│ ├── templates.py
183
+
│ ├── user.py
184
+
│ └── user_preferences.py
125
185
└── utils.py
126
186
```
127
187
128
-
**Let me explain how the library is structured:**
188
+
### Project Components
189
+
190
+
#### API
191
+
192
+
The `api.py` file contains all the api calls to the WhatsApp Cloud API. It is responsible for sending requests to the
193
+
WhatsApp Cloud API and returning their raw responses.
194
+
195
+
#### Client
196
+
197
+
The `WhatsApp` class in the `client.py` file is a wrapper around the api calls. It is responsible for sending requests
198
+
to the WhatsApp Cloud API and returning the parsed responses. It allows to send messages, upload media, manage profiles,
199
+
flows, templates, and more.
200
+
201
+
#### Server
202
+
203
+
The `Server` class in the `server.py` file is responsible for handling, verifying and parsing the incoming updates from
204
+
the webhook. It is also responsible for registering the webhook routes and the callback url.
129
205
130
-
### API
131
-
The `api.py` file contains all the api calls to the WhatsApp Cloud API. It responsible for sending requests to the WhatsApp Cloud API and returning their raw responses.
206
+
#### Handlers
132
207
133
-
### Client
134
-
The `WhatsApp` class in the `client.py` file is a wrapper around the api calls. It responsible for sending requests to the WhatsApp Cloud API and returning the parsed responses.
135
-
It allows to send messages, upload media, manage profiles, flows, templates, and more.
208
+
The `handlers.py` file contains the handler decorators and their respective handler objects. The handlers are used to
209
+
handle incoming updates from the webhook.
136
210
137
-
### Server
138
-
The `Server` class in the `server.py` file is responsible for handling, verifying and parsing the incoming updates from the webhook.
139
-
It also responsible for registering the webhook routes and the callback url.
211
+
#### Listeners
140
212
141
-
### Handlers
142
-
The `handlers.py` file contains the handler decorators and their respective handler objects. The handlers are used to handle incoming updates from the webhook.
213
+
The `listeners.py` file contains the listener functions and the logic to wait and listen to specific updates.
143
214
144
-
### Listeners
145
-
The `listeners.py` file contains the listener functions and the logic to wait and listen to specific user updates.
215
+
#### Filters
146
216
147
-
### Filters
148
217
The `filters.py` file contains the filters to use in the handlers to filter incoming updates.
149
218
150
-
### Types
151
-
The `types` package contains the data classes representing the different types of updates and messages.
219
+
#### Types
152
220
153
-
### Utils
154
-
Contains utility functions used across the library and by the users (not like `_helpers.py` which is used internally).
221
+
The `types` package contains the data classes representing the different types of updates, messages, templates, flows,
222
+
business profiles, calling settings, etc.
223
+
224
+
#### Utils
225
+
226
+
Contains utility functions used across the library and by the users (unlike `_helpers.py` which is used internally).
227
+
228
+
#### Errors
155
229
156
-
### Errors
157
230
Contains the custom exceptions used in the library.
158
231
159
-
### Async
160
-
The async version of pywa preserves the same structure as the sync version.
161
-
Most of the code in the async version is inherited from the sync version, while overriding every api-related method to be async.
162
-
So when you make changes to the sync version, make sure to apply the same changes to the async version.
232
+
#### CLI
233
+
234
+
The `cli.py` and `__main__.py` files implement the command line interface (run using the `pywa` command) to run the dev
235
+
server, send messages etc.
236
+
237
+
#### Async
238
+
239
+
The async version of pywa (`pywa_async`) preserves the same structure as the sync version (`pywa`). Most of the code in
240
+
the async version is inherited from the sync version, while overriding every api-related method to be async. So when you
241
+
make changes to the sync version, make sure to apply the same changes to the async version.
242
+
243
+
#### Docs
244
+
245
+
The documentation is written in reStructuredText and is located in the `docs/source/content` directory. The
246
+
documentation is built using Sphinx and hosted on ReadTheDocs.
247
+
248
+
#### Tests
163
249
164
-
### Docs
165
-
The documentation is written in reStructuredText and is located in the `docs/source/content` directory. The documentation is built using Sphinx and hosted on ReadTheDocs.
250
+
The tests are located in the `tests` directory and are written using `pytest`.
166
251
167
-
### Tests
168
-
The tests are located in the `tests` directory. The tests are written using `pytest`.
252
+
- Run all tests:
253
+
```bash
254
+
pytest
255
+
```
256
+
- When adding new features or fixing bugs, please write corresponding tests:
257
+
- Add tests for client methods/options in `test_client.py` and `test_async.py`.
258
+
- Add tests for new filters in `test_filters.py`.
259
+
- Add tests for new types/updates in `test_types.py` or `test_updates.py`.
0 commit comments