Skip to content

Commit

Permalink
Merge pull request #77 from livechat/update-httpx-dependency
Browse files Browse the repository at this point in the history
Update `httpx` dependency and documentation
  • Loading branch information
kacperf531 authored May 26, 2022
2 parents a938c2b + 8e1cd71 commit d769a86
Show file tree
Hide file tree
Showing 7 changed files with 343 additions and 316 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name = "pypi"
[packages]
websocket-client= "1.2.1"
urllib3 = "1.26.6"
httpx = {extras = ["http2"], version = "0.19.0"}
httpx = {extras = ["http2"], version = "0.23.0"}

[dev-packages]
pre-commit = "2.10.1"
Expand Down
542 changes: 319 additions & 223 deletions Pipfile.lock

Large diffs are not rendered by default.

99 changes: 8 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ For protocol documentation of LiveChat APIs, please go to [Livechat Platform Doc
## Technical docs

Agent Chat API:
* [RTM API](https://livechat.github.io/lc-sdk-python/agent_rtm.html)
* [WEB API](https://livechat.github.io/lc-sdk-python/agent_web.html)
* [RTM API](https://livechat.github.io/lc-sdk-python/agent_rtm/index.html)
* [WEB API](https://livechat.github.io/lc-sdk-python/agent_web/index.html)

Customer Chat API:
* [RTM API](https://livechat.github.io/lc-sdk-python/customer_rtm.html)
* [WEB API](https://livechat.github.io/lc-sdk-python/customer_web.html)
* [RTM API](https://livechat.github.io/lc-sdk-python/customer_rtm/index.html)
* [WEB API](https://livechat.github.io/lc-sdk-python/customer_web/index.html)

Management:
* [Configuration API](https://livechat.github.io/lc-sdk-python/configuration_api.html)
* [Configuration API](https://livechat.github.io/lc-sdk-python/configuration/index.html)

Reports:
* [Reports API](https://livechat.github.io/lc-sdk-python/reports_api.html)
* [Reports API](https://livechat.github.io/lc-sdk-python/reports/index.html)

## Installation

Expand All @@ -32,91 +32,8 @@ pip install lc-sdk-python

## Usage

### Agent RTM API usage example

Basic example on how to login as an agent and change routing status to `not_accepting_chats`.

First, create your AgentRTM client and log in:
```python
>>> from livechat.agent import AgentRTM
>>> my_agent = AgentRTM.get_client()
>>> my_agent.login(token='Bearer <your bearer token>')
INFO:root:
REQUEST:
{
"action": "login",
"payload": {
"token": "Bearer <your bearer token>
},
"request_id": "5571081909"
}
INFO:root:
RESPONSES:
{
"response": {
"request_id": "5571081909",
"action": "login",
"type": "response",
"payload": {
...
},
"success": true
},
"pushes": []
}
```

Now you can change the routing status of the agent:

```python
>>> my_agent.set_routing_status(status='not_accepting_chats')
INFO:root:
REQUEST:
{
"action": "set_routing_status",
"payload": {
"status": "not_accepting_chats"
},
"request_id": "8214452850"
}
INFO:root:
RESPONSES:
{
"response": {
"request_id": "8214452850",
"action": "set_routing_status",
"type": "response",
"payload": {},
"success": true
...
}
}
```

Finally, log out:

```python
>>> my_agent.logout()
INFO:root:
REQUEST:
{
"action": "logout",
"payload": {},
"request_id": "629300202"
}
INFO:root:
RESPONSES:
{
"response": {
"request_id": "629300202",
"action": "logout",
"type": "response",
"success": true
},
"pushes": []
}
```

Usage examples can be found here:
[examples](https://github.com/livechat/lc-sdk-python/tree/master/examples)

## Feedback

Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Change Log
All notable changes to this project will be documented in this file.

## [0.3.1] - 2022-05-26

### Changed
- Updated httpx dependency to a version which fixes a potential vulnerability.
- Updated readme file and extended examples with getting pushes from the websocket client.

## [0.3.0] - 2022-05-10

### Added
Expand Down
4 changes: 4 additions & 0 deletions examples/agent_rtm_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
response = agent_rtm.start_chat(continuous=True)
chat_id = response.payload.get('chat_id')
thread_id = response.payload.get('thread_id')

# Get `incoming_chat` push from all messages including the non-response messages (i.e. pushes)
incoming_chat_push = agent_rtm.ws.messages[0]

agent_rtm.send_event(chat_id=chat_id,
event={
'type': 'message',
Expand Down
4 changes: 4 additions & 0 deletions examples/customer_rtm_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
response = customer_rtm.start_chat(continuous=True)
chat_id = response.payload.get('chat_id')
thread_id = response.payload.get('thread_id')

# Get `incoming_chat` push from all messages including the non-response messages (i.e. pushes)
incoming_chat_push = customer_rtm.ws.messages[0]

customer_rtm.send_event(chat_id=chat_id,
event={
'type': 'message',
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = lc-sdk-python
version = 0.3.0
version = 0.3.1
description = Package which lets to work with LiveChat API.
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down

0 comments on commit d769a86

Please sign in to comment.