{"action":"created","comment":{"url":"https://api.github.com/repos/lob/lob-python/pulls/comments/84563144","pull_request_review_id":5337232,"id":84563144,"diff_hunk":"@@ -0,0 +1,183 @@\n+# usage:\n+#   python check.py input.csv\n+#   logs to csv's in the output directory\n+\n+import csv\n+import datetime\n+import lob\n+import os\n+import sys\n+\n+sys.path.insert(0, os.path.abspath(__file__+'../../..'))\n+\n+###########################################################\n+# TODO: Provide your API Key, keep this secure\n+lob.api_key = 'test_fc26575412e92e22a926bc96c857f375f8b'\n+\n+# TODO: Create your from_address\n+try:\n+    from_address = lob.Address.create(\n+            name='Your Name',\n+            company='Your Company',\n+            address_line1='123 Test Avenue',\n+            address_line2='STE 456',\n+            address_city='San Francisco',\n+            address_state='CA',\n+            address_zip='94107'\n+            )\n+except Exception, e:\n+    print('Error: ' + str(e))\n+    print('Failed to create from_address.')\n+    sys.exit(1)\n+\n+# TODO: Create and verify your bank account\n+try:\n+    bank_account = lob.BankAccount.create(\n+            description='Your Bank Account',\n+            routing_number='122100024',\n+            account_number='0123456478',\n+            account_type='company',\n+            signatory='John Hancock'\n+            )\n+except Exception, e:\n+    print('Error: ' + str(e))\n+    print('Failed to create bank account')\n+    sys.exit(1)\n+\n+try:\n+    example_bank_account = lob.BankAccount.verify(\n+            id=bank_account.id,\n+            amounts=[23, 77]\n+            )\n+except Exception, e:\n+    print('Error: ' + str(e))\n+    print('Failed to verify bank account.')\n+\n+# TODO: Add a logo to your check\n+CHECK_LOGO = 'https://s3-us-west-2.amazonaws.com/lob-assets/lob_check_logo.png'\n+\n+###########################################################\n+\n+# Input check\n+if len(sys.argv) < 2:\n+    print(\"Please provide an input CSV file as an argument.\")\n+    print(\"usage: python check.py <CSV_FILE>\")\n+    sys.exit(1)\n+\n+input_filename = sys.argv[1]\n+\n+success_csv_fields = [\n+        'name',\n+        'id',\n+        'url',\n+        'address_line1',\n+        'address_line2',\n+        'address_city',\n+        'address_state',\n+        'address_zip'\n+        ]\n+\n+errors_csv_fields = ['error']\n+\n+# create the output directory,\n+output_dir = os.path.join('.',  'output')\n+if not os.path.isdir(output_dir):\n+    os.mkdir(output_dir)\n+\n+timestamp = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')\n+\n+try:\n+    output_dir = os.path.join(output_dir, timestamp)\n+    os.mkdir(output_dir)\n+except Exception, e:\n+    print('Error: ' + str(e))\n+    print('Failed to create output directory. Aborting all sends.')\n+    sys.exit(1)\n+\n+# output csv names\n+success_filename = os.path.join(output_dir, 'success.csv')\n+errors_filename = os.path.join(output_dir, 'errors.csv')\n+\n+with open('check.html', 'r') as html_file:\n+    check_html = html_file.read()\n+\n+try:\n+    with open(input_filename, 'r') as input, \\\n+            open(success_filename, 'w') as success, \\\n+            open(errors_filename, 'w') as errors:\n+\n+                # Print mode to screen\n+        mode = lob.api_key.split('_')[0]\n+        print('Sending checks in ' + mode.upper() + ' mode.')\n+\n+        input_csv = csv.DictReader(input)\n+        errors_csv_fields += input_csv.fieldnames\n+\n+        success_csv = csv.DictWriter(success, fieldnames=success_csv_fields)\n+        errors_csv = csv.DictWriter(errors, fieldnames=errors_csv_fields)\n+        success_csv.writeheader()\n+        errors_csv.writeheader()\n+\n+        err_count = 0\n+        # Loop through input CSV rows\n+        for idx, row in enumerate(input_csv):\n+            # Create checks from row\n+            try:\n+                check = lob.Check.create(\n+                        description='Check for ' + row['name'],\n+                        metadata={\n+                            'csv': input_filename\n+                            },\n+                        to_address={\n+                            'name':          row['name'],\n+                            'address_line1': row['address_line1'],\n+                            'address_line2': row['address_line2'],\n+                            'address_city':  row['address_city'],\n+                            'address_zip':   row['address_zip'],\n+                            'address_state': row['address_state']\n+                            },\n+                        from_address=from_address,\n+                        bank_account=bank_account,\n+                        amount=row['amount'],\n+                        memo='Service payment',\n+                        check_bottom=check_html,\n+                        data={\n+                            'name': row['name'],\n+                            },","path":"examples/create_checks_from_csv/check.py","position":146,"original_position":146,"commit_id":"0a0fb7c5fc1b1db34b7413376a198b939dc1ddfc","original_commit_id":"0a0fb7c5fc1b1db34b7413376a198b939dc1ddfc","user":{"login":"peterdolan","id":4510996,"avatar_url":"https://avatars.githubusercontent.com/u/4510996?v=3","gravatar_id":"","url":"https://api.github.com/users/peterdolan","html_url":"https://github.com/peterdolan","followers_url":"https://api.github.com/users/peterdolan/followers","following_url":"https://api.github.com/users/peterdolan/following{/other_user}","gists_url":"https://api.github.com/users/peterdolan/gists{/gist_id}","starred_url":"https://api.github.com/users/peterdolan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterdolan/subscriptions","organizations_url":"https://api.github.com/users/peterdolan/orgs","repos_url":"https://api.github.com/users/peterdolan/repos","events_url":"https://api.github.com/users/peterdolan/events{/privacy}","received_events_url":"https://api.github.com/users/peterdolan/received_events","type":"User","site_admin":false},"body":"And here","created_at":"2016-10-22T00:02:56Z","updated_at":"2016-10-22T00:04:17Z","html_url":"https://github.com/lob/lob-python/pull/124#discussion_r84563144","pull_request_url":"https://api.github.com/repos/lob/lob-python/pulls/124","_links":{"self":{"href":"https://api.github.com/repos/lob/lob-python/pulls/comments/84563144"},"html":{"href":"https://github.com/lob/lob-python/pull/124#discussion_r84563144"},"pull_request":{"href":"https://api.github.com/repos/lob/lob-python/pulls/124"}}},"pull_request":{"url":"https://api.github.com/repos/lob/lob-python/pulls/124","id":89435578,"html_url":"https://github.com/lob/lob-python/pull/124","diff_url":"https://github.com/lob/lob-python/pull/124.diff","patch_url":"https://github.com/lob/lob-python/pull/124.patch","issue_url":"https://api.github.com/repos/lob/lob-python/issues/124","number":124,"state":"open","locked":false,"title":"feat(checks): adds create check from csv example","user":{"login":"sjl2","id":8300986,"avatar_url":"https://avatars.githubusercontent.com/u/8300986?v=3","gravatar_id":"","url":"https://api.github.com/users/sjl2","html_url":"https://github.com/sjl2","followers_url":"https://api.github.com/users/sjl2/followers","following_url":"https://api.github.com/users/sjl2/following{/other_user}","gists_url":"https://api.github.com/users/sjl2/gists{/gist_id}","starred_url":"https://api.github.com/users/sjl2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjl2/subscriptions","organizations_url":"https://api.github.com/users/sjl2/orgs","repos_url":"https://api.github.com/users/sjl2/repos","events_url":"https://api.github.com/users/sjl2/events{/privacy}","received_events_url":"https://api.github.com/users/sjl2/received_events","type":"User","site_admin":false},"body":"JIRA: ENG-1199\r\n\r\n## What:\r\n- Adds create checks from csv example\r\n- Fixes letters from csv example to have better error checking\r\n- Cosmetic fix in postcards\r\n\r\n## Why:\r\n- To have consistent examples for our core products","created_at":"2016-10-14T18:51:02Z","updated_at":"2016-10-22T00:04:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"69103a8379623528d159969284e039087fd70684","assignee":{"login":"peterdolan","id":4510996,"avatar_url":"https://avatars.githubusercontent.com/u/4510996?v=3","gravatar_id":"","url":"https://api.github.com/users/peterdolan","html_url":"https://github.com/peterdolan","followers_url":"https://api.github.com/users/peterdolan/followers","following_url":"https://api.github.com/users/peterdolan/following{/other_user}","gists_url":"https://api.github.com/users/peterdolan/gists{/gist_id}","starred_url":"https://api.github.com/users/peterdolan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterdolan/subscriptions","organizations_url":"https://api.github.com/users/peterdolan/orgs","repos_url":"https://api.github.com/users/peterdolan/repos","events_url":"https://api.github.com/users/peterdolan/events{/privacy}","received_events_url":"https://api.github.com/users/peterdolan/received_events","type":"User","site_admin":false},"assignees":[{"login":"peterdolan","id":4510996,"avatar_url":"https://avatars.githubusercontent.com/u/4510996?v=3","gravatar_id":"","url":"https://api.github.com/users/peterdolan","html_url":"https://github.com/peterdolan","followers_url":"https://api.github.com/users/peterdolan/followers","following_url":"https://api.github.com/users/peterdolan/following{/other_user}","gists_url":"https://api.github.com/users/peterdolan/gists{/gist_id}","starred_url":"https://api.github.com/users/peterdolan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterdolan/subscriptions","organizations_url":"https://api.github.com/users/peterdolan/orgs","repos_url":"https://api.github.com/users/peterdolan/repos","events_url":"https://api.github.com/users/peterdolan/events{/privacy}","received_events_url":"https://api.github.com/users/peterdolan/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/lob/lob-python/pulls/124/commits","review_comments_url":"https://api.github.com/repos/lob/lob-python/pulls/124/comments","review_comment_url":"https://api.github.com/repos/lob/lob-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lob/lob-python/issues/124/comments","statuses_url":"https://api.github.com/repos/lob/lob-python/statuses/0a0fb7c5fc1b1db34b7413376a198b939dc1ddfc","head":{"label":"lob:checks-from-csv-example","ref":"checks-from-csv-example","sha":"0a0fb7c5fc1b1db34b7413376a198b939dc1ddfc","user":{"login":"lob","id":4955790,"avatar_url":"https://avatars.githubusercontent.com/u/4955790?v=3","gravatar_id":"","url":"https://api.github.com/users/lob","html_url":"https://github.com/lob","followers_url":"https://api.github.com/users/lob/followers","following_url":"https://api.github.com/users/lob/following{/other_user}","gists_url":"https://api.github.com/users/lob/gists{/gist_id}","starred_url":"https://api.github.com/users/lob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lob/subscriptions","organizations_url":"https://api.github.com/users/lob/orgs","repos_url":"https://api.github.com/users/lob/repos","events_url":"https://api.github.com/users/lob/events{/privacy}","received_events_url":"https://api.github.com/users/lob/received_events","type":"Organization","site_admin":false},"repo":{"id":11316875,"name":"lob-python","full_name":"lob/lob-python","owner":{"login":"lob","id":4955790,"avatar_url":"https://avatars.githubusercontent.com/u/4955790?v=3","gravatar_id":"","url":"https://api.github.com/users/lob","html_url":"https://github.com/lob","followers_url":"https://api.github.com/users/lob/followers","following_url":"https://api.github.com/users/lob/following{/other_user}","gists_url":"https://api.github.com/users/lob/gists{/gist_id}","starred_url":"https://api.github.com/users/lob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lob/subscriptions","organizations_url":"https://api.github.com/users/lob/orgs","repos_url":"https://api.github.com/users/lob/repos","events_url":"https://api.github.com/users/lob/events{/privacy}","received_events_url":"https://api.github.com/users/lob/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lob/lob-python","description":"Python Wrapper for Lob API","fork":false,"url":"https://api.github.com/repos/lob/lob-python","forks_url":"https://api.github.com/repos/lob/lob-python/forks","keys_url":"https://api.github.com/repos/lob/lob-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lob/lob-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lob/lob-python/teams","hooks_url":"https://api.github.com/repos/lob/lob-python/hooks","issue_events_url":"https://api.github.com/repos/lob/lob-python/issues/events{/number}","events_url":"https://api.github.com/repos/lob/lob-python/events","assignees_url":"https://api.github.com/repos/lob/lob-python/assignees{/user}","branches_url":"https://api.github.com/repos/lob/lob-python/branches{/branch}","tags_url":"https://api.github.com/repos/lob/lob-python/tags","blobs_url":"https://api.github.com/repos/lob/lob-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lob/lob-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lob/lob-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/lob/lob-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lob/lob-python/statuses/{sha}","languages_url":"https://api.github.com/repos/lob/lob-python/languages","stargazers_url":"https://api.github.com/repos/lob/lob-python/stargazers","contributors_url":"https://api.github.com/repos/lob/lob-python/contributors","subscribers_url":"https://api.github.com/repos/lob/lob-python/subscribers","subscription_url":"https://api.github.com/repos/lob/lob-python/subscription","commits_url":"https://api.github.com/repos/lob/lob-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/lob/lob-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/lob/lob-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/lob/lob-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/lob/lob-python/contents/{+path}","compare_url":"https://api.github.com/repos/lob/lob-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lob/lob-python/merges","archive_url":"https://api.github.com/repos/lob/lob-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lob/lob-python/downloads","issues_url":"https://api.github.com/repos/lob/lob-python/issues{/number}","pulls_url":"https://api.github.com/repos/lob/lob-python/pulls{/number}","milestones_url":"https://api.github.com/repos/lob/lob-python/milestones{/number}","notifications_url":"https://api.github.com/repos/lob/lob-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lob/lob-python/labels{/name}","releases_url":"https://api.github.com/repos/lob/lob-python/releases{/id}","deployments_url":"https://api.github.com/repos/lob/lob-python/deployments","created_at":"2013-07-10T16:10:19Z","updated_at":"2016-02-20T06:24:34Z","pushed_at":"2016-10-14T18:51:29Z","git_url":"git://github.com/lob/lob-python.git","ssh_url":"git@github.com:lob/lob-python.git","clone_url":"https://github.com/lob/lob-python.git","svn_url":"https://github.com/lob/lob-python","homepage":"lob.com","size":3074,"stargazers_count":37,"watchers_count":37,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":1,"forks":26,"open_issues":1,"watchers":37,"default_branch":"master"}},"base":{"label":"lob:master","ref":"master","sha":"b9ceb2aadb6646841051f54602d53c2f1cba36aa","user":{"login":"lob","id":4955790,"avatar_url":"https://avatars.githubusercontent.com/u/4955790?v=3","gravatar_id":"","url":"https://api.github.com/users/lob","html_url":"https://github.com/lob","followers_url":"https://api.github.com/users/lob/followers","following_url":"https://api.github.com/users/lob/following{/other_user}","gists_url":"https://api.github.com/users/lob/gists{/gist_id}","starred_url":"https://api.github.com/users/lob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lob/subscriptions","organizations_url":"https://api.github.com/users/lob/orgs","repos_url":"https://api.github.com/users/lob/repos","events_url":"https://api.github.com/users/lob/events{/privacy}","received_events_url":"https://api.github.com/users/lob/received_events","type":"Organization","site_admin":false},"repo":{"id":11316875,"name":"lob-python","full_name":"lob/lob-python","owner":{"login":"lob","id":4955790,"avatar_url":"https://avatars.githubusercontent.com/u/4955790?v=3","gravatar_id":"","url":"https://api.github.com/users/lob","html_url":"https://github.com/lob","followers_url":"https://api.github.com/users/lob/followers","following_url":"https://api.github.com/users/lob/following{/other_user}","gists_url":"https://api.github.com/users/lob/gists{/gist_id}","starred_url":"https://api.github.com/users/lob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lob/subscriptions","organizations_url":"https://api.github.com/users/lob/orgs","repos_url":"https://api.github.com/users/lob/repos","events_url":"https://api.github.com/users/lob/events{/privacy}","received_events_url":"https://api.github.com/users/lob/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lob/lob-python","description":"Python Wrapper for Lob API","fork":false,"url":"https://api.github.com/repos/lob/lob-python","forks_url":"https://api.github.com/repos/lob/lob-python/forks","keys_url":"https://api.github.com/repos/lob/lob-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lob/lob-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lob/lob-python/teams","hooks_url":"https://api.github.com/repos/lob/lob-python/hooks","issue_events_url":"https://api.github.com/repos/lob/lob-python/issues/events{/number}","events_url":"https://api.github.com/repos/lob/lob-python/events","assignees_url":"https://api.github.com/repos/lob/lob-python/assignees{/user}","branches_url":"https://api.github.com/repos/lob/lob-python/branches{/branch}","tags_url":"https://api.github.com/repos/lob/lob-python/tags","blobs_url":"https://api.github.com/repos/lob/lob-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lob/lob-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lob/lob-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/lob/lob-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lob/lob-python/statuses/{sha}","languages_url":"https://api.github.com/repos/lob/lob-python/languages","stargazers_url":"https://api.github.com/repos/lob/lob-python/stargazers","contributors_url":"https://api.github.com/repos/lob/lob-python/contributors","subscribers_url":"https://api.github.com/repos/lob/lob-python/subscribers","subscription_url":"https://api.github.com/repos/lob/lob-python/subscription","commits_url":"https://api.github.com/repos/lob/lob-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/lob/lob-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/lob/lob-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/lob/lob-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/lob/lob-python/contents/{+path}","compare_url":"https://api.github.com/repos/lob/lob-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lob/lob-python/merges","archive_url":"https://api.github.com/repos/lob/lob-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lob/lob-python/downloads","issues_url":"https://api.github.com/repos/lob/lob-python/issues{/number}","pulls_url":"https://api.github.com/repos/lob/lob-python/pulls{/number}","milestones_url":"https://api.github.com/repos/lob/lob-python/milestones{/number}","notifications_url":"https://api.github.com/repos/lob/lob-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lob/lob-python/labels{/name}","releases_url":"https://api.github.com/repos/lob/lob-python/releases{/id}","deployments_url":"https://api.github.com/repos/lob/lob-python/deployments","created_at":"2013-07-10T16:10:19Z","updated_at":"2016-02-20T06:24:34Z","pushed_at":"2016-10-14T18:51:29Z","git_url":"git://github.com/lob/lob-python.git","ssh_url":"git@github.com:lob/lob-python.git","clone_url":"https://github.com/lob/lob-python.git","svn_url":"https://github.com/lob/lob-python","homepage":"lob.com","size":3074,"stargazers_count":37,"watchers_count":37,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":1,"forks":26,"open_issues":1,"watchers":37,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lob/lob-python/pulls/124"},"html":{"href":"https://github.com/lob/lob-python/pull/124"},"issue":{"href":"https://api.github.com/repos/lob/lob-python/issues/124"},"comments":{"href":"https://api.github.com/repos/lob/lob-python/issues/124/comments"},"review_comments":{"href":"https://api.github.com/repos/lob/lob-python/pulls/124/comments"},"review_comment":{"href":"https://api.github.com/repos/lob/lob-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lob/lob-python/pulls/124/commits"},"statuses":{"href":"https://api.github.com/repos/lob/lob-python/statuses/0a0fb7c5fc1b1db34b7413376a198b939dc1ddfc"}}}}
{"actor":{"display_login":"peterdolan"}}