Created
November 2, 2012 17:01
-
-
Save thinkjson/4002720 to your computer and use it in GitHub Desktop.
Open sprint.ly tickets from Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urllib2 | |
| import base64 | |
| from urllib import urlencode | |
| SPRINTLY_USERNAME = '' | |
| SPRINTLY_API_KEY = '' | |
| SPRINTLY_PROJECT = '' | |
| class Sprintly(): | |
| """ | |
| Open a new sprint.ly ticket | |
| Arguments | |
| type (string, required) What kind of item you'd like to create. | |
| Only story, task, defect, and test are valid values. | |
| title (string, required for task, defect, and test) The title of item. | |
| who (string, required for story) The who part of the story. | |
| what (string, required for story) The what part of the story. | |
| why (string, required for story) The why part of the story. | |
| description (string) A description detailing the item. Markdown is allowed. | |
| score (string) The initial score of the document. | |
| Only ~, S, M, L, and XL are valid values. | |
| status (string): Status of the new item. Default is backlog. | |
| Only backlog, in-progress, completed, and accepted are valid values. | |
| assigned_to (integer) The user's id which the item should assigned to. | |
| tags (string) A comma separated list of tags to assign to the item | |
| (e.g. foo,bar,some other tag,baz). | |
| """ | |
| def __init__(self, **kwargs): | |
| self.data = kwargs | |
| def save(self): | |
| request = urllib2.Request( | |
| "https://sprint.ly/api/products/%s/items.json" % SPRINTLY_PROJECT, | |
| urlencode(self.data)) | |
| base64string = base64.encodestring( | |
| '%s:%s' % (SPRINTLY_USERNAME, SPRINTLY_API_KEY)).replace('\n', '') | |
| request.add_header("Authorization", "Basic %s" % base64string) | |
| response = urllib2.urlopen(request) | |
| return response | |
| if __name__ == '__main__': | |
| ticket = Sprintly(type='story', who='user', | |
| what='python sprint.ly integration', | |
| why='I can open tickets from my python applications', | |
| description='This is pretty cool!', | |
| tags='python') | |
| ticket.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment