Skip to content

Commit

Permalink
Merge pull request #1 from take-kun/release/0.1.1
Browse files Browse the repository at this point in the history
release: Release 0.1.1
  • Loading branch information
take-kun authored Oct 24, 2022
2 parents bd1a313 + fd5f775 commit 7553465
Show file tree
Hide file tree
Showing 55 changed files with 103,192 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
47665dc3f4df6a6f81fd32dcf323ed86e3ab7b18

21 changes: 21 additions & 0 deletions .github/workflows/build/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Reusable build workflow
description: Use prepended with actions/checkout@v3 action to achieve built project package in dist directory

runs:
using: composite
steps:
- name: Install poetry
shell: bash
run: pipx install poetry
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: poetry
- name: Install dependencies
shell: bash
run: poetry install
- name: Build distributions
shell: bash
run: poetry build

59 changes: 59 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: mercapi CI

on:
- push
- pull_request

jobs:
lint:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
cache-dependency-path: '**/poetry.lock'

- name: Install black
run: pip install black

- name: Check Linting
run: black --check mercapi/ tests/

test:
name: Unit test
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install poetry
run: pipx install poetry

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"

- name: Update pip
run: python -m pip install --upgrade pip

- name: Install dependencies
run: poetry install

- name: Test with pytest
run: poetry run pytest
37 changes: 37 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build and publish docs

on:
release:
types:
- 'released'
workflow_dispatch:


jobs:
build_docs:
name: Build docs
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install poetry
run: pipx install poetry

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: poetry

- name: Install dependencies (docs only)
run: poetry install --only docs

- name: Build docs
run: pdoc mercapi -o ./html

- name: Publish to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./html
25 changes: 25 additions & 0 deletions .github/workflows/release-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish to TestPyPI

on:
push:
branches:
- main
- 'release/**'

jobs:
publish_test:

runs-on: "ubuntu-latest"

steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Build distributions
uses: ./.github/workflows/build

- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
23 changes: 23 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish to PyPI

on:
release:
types:
- 'released'

jobs:
publish_test:

runs-on: "ubuntu-latest"

steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Build distributions
uses: ./.github/workflows/build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,6 @@ venv.bak/

# VSCode
.vscode/

# pdoc output
html/
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## What is Mercapi?

Mercapi is a Python wrapper for *mercari.jp* API.
It's capable of producing HTTP requests implementing security mechanisms employed in native *mercari.jp* web app.
Requests and responses are mapped to custom classes with type-hinting and documentation.

## Quickstart

First, install the `mercapi` package using the package manager of your choice.

As an example, we want to run the search query `sharpnel`.

```python
from mercapi import Mercapi


m = Mercapi()
results = await m.search('sharpnel')

print(f'Found {results.meta.num_found} results')
for item in results.items:
print(f'Name: {item.name}\\nPrice: {item.price}\\n')

```

We can use a single result object to retrieve full details of the listing.
```python
item = results.items[0]
full_item = await item.full_item()

print(full_item.description)
```

Or get it directly using an ID.
```python
item = await m.item('m90925725213')

print(item.description)
```

Refer to `mercapi.mercapi.Mercapi` documentation for all implemented features.

*Examples above are not executable. If you want to try them out, run `python example.py`.*
Loading

0 comments on commit 7553465

Please sign in to comment.