Skip to content

Commit 9cfcdb2

Browse files
Merge pull request #19 from Staffjoy/updates
update dev, bump release, update formatting
2 parents 481038f + 88ff409 commit 9cfcdb2

File tree

8 files changed

+26
-28
lines changed

8 files changed

+26
-28
lines changed

LICENSE.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
MIT License
2-
Copyright (c) 2016 Staffjoy, Inc.
2+
3+
Copyright (c) 2016-2017 Staffjoy, Inc.
34

45
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
56

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ A light wrapper for the [Staffjoy](https://www.staffjoy.com) API in Python.
44

55
This library does not include permissions management, and it is primarily used across microservices internally. Some of its features include internal-only endpoints.
66

7-
[![Build Status](https://travis-ci.org/Staffjoy/client_python.svg?branch=master)](https://travis-ci.org/Staffjoy/client_python)
7+
[![Build Status](https://travis-ci.org/Staffjoy/client_python.svg?branch=master)](https://travis-ci.org/Staffjoy/client_python) [![Moonlight](https://img.shields.io/badge/Contractors-1-brightgreen.svg)](https://moonlightwork.com/staffjoy)
88

99
## Installation
1010

11-
`pip install staffjoy`
11+
`pip install --upgrade staffjoy`
1212

1313
## Authentication
1414

@@ -22,11 +22,7 @@ To get your organization ID, look at the URL path when you go to the Manager app
2222

2323
## Rate Limits
2424

25-
This client sleeps for .5 seconds after every request. Thus, in a single thread, requests are limited to 120 per minute. This is done to avoid rate limiting. Staffjoy's API currently rate limits to 300 requests per second across keys and IPs. Thus, by using this library, you should never encounter a rate limit (assuming one executing thread per IP address).
26-
27-
## Updates
28-
29-
If you use this library, please subscribe to the [Staffjoy API Updates Google Group](https://groups.google.com/forum/#!forum/staffjoy-api-updates) for important notifications about changes and deprecations.
25+
This client sleeps after every request in order to limit requests to 120 per minute. This is done to avoid rate limiting. Staffjoy's API currently rate limits to 300 requests per second across keys and IPs. Thus, by using this library, you should never encounter a rate limit (assuming one executing thread per IP address).
3026

3127
## Usage
3228

requirements-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
yapf==0.10.0
1+
yapf==0.16.0
22
pytest==2.8.7

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from setuptools import setup, find_packages
22

3-
version = "0.22"
3+
version = "0.23"
44
setup(name="staffjoy",
55
packages=find_packages(),
66
version=version,
77
description="Staffjoy API Wrapper in Python",
88
author="Philip Thomas",
9-
author_email="help@staffjoy.com",
9+
author_email="philip@staffjoy.com",
1010
license="MIT",
1111
url="https://github.com/staffjoy/client_python",
1212
download_url="https://github.com/StaffJoy/client_python/archive/%s.tar.gz" % version,

staffjoy/client.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99

1010
class Client(Resource):
1111
def get_organizations(self, limit=25, offset=0, **kwargs):
12-
return Organization.get_all(parent=self,
13-
limit=limit,
14-
offset=offset,
15-
**kwargs)
12+
return Organization.get_all(
13+
parent=self, limit=limit, offset=offset, **kwargs)
1614

1715
def get_organization(self, id):
1816
return Organization.get(parent=self, id=id)

staffjoy/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class StageConfig(DefaultConfig):
1616
class DevelopmentConfig(DefaultConfig):
1717
ENV = "dev"
1818
LOG_LEVEL = logging.DEBUG
19-
BASE = "http://dev.staffjoy.com/api/v2/"
19+
BASE = "http://suite.local/api/v2/"
2020

2121

2222
config_from_env = { # Determined in main.py

staffjoy/resource.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ class Resource:
1717
ID_NAME = None # What is this ID called in the route of children?
1818
META_ENVELOPES = [] # Metadata keys for what to unpack from response
1919
ENVELOPE = "data" # We "envelope" response data in the "data" section
20-
TRUTHY_CODES = [requests.codes.ok, requests.codes.created,
21-
requests.codes.no_content, requests.codes.accepted]
20+
TRUTHY_CODES = [
21+
requests.codes.ok, requests.codes.created, requests.codes.no_content,
22+
requests.codes.accepted
23+
]
2224

2325
def __init__(self,
2426
key="",
@@ -75,9 +77,8 @@ def get_all(cls, parent=None, **params):
7577
"""Perform a read request against the resource"""
7678

7779
start = datetime.now()
78-
r = requests.get(base_obj._url(),
79-
auth=(base_obj.key, ""),
80-
params=params)
80+
r = requests.get(
81+
base_obj._url(), auth=(base_obj.key, ""), params=params)
8182
cls._delay_for_ratelimits(start)
8283

8384
if r.status_code not in cls.TRUTHY_CODES:
@@ -89,10 +90,11 @@ def get_all(cls, parent=None, **params):
8990
return_objects = []
9091
for data in objects_data:
9192
# Note that this approach does not get meta data
92-
return_objects.append(cls.get(parent=parent,
93-
id=data.get(cls.ID_NAME, data.get(
94-
"id")),
95-
data=data))
93+
return_objects.append(
94+
cls.get(
95+
parent=parent,
96+
id=data.get(cls.ID_NAME, data.get("id")),
97+
data=data))
9698

9799
return return_objects
98100

test/test_functional.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ def test_org_crud():
5858
r.patch(name="Cocina")
5959
logger.debug("Adding worker")
6060
r.get_workers()
61-
r.create_worker(email=TEST_WORKER,
62-
min_hours_per_workweek=30,
63-
max_hours_per_workweek=40)
61+
r.create_worker(
62+
email=TEST_WORKER,
63+
min_hours_per_workweek=30,
64+
max_hours_per_workweek=40)
6465

6566
logger.debug("Deleting worker")
6667
r.delete()

0 commit comments

Comments
 (0)