{"id":17153874,"url":"https://github.com/stevenmmortimer/squareupr","last_synced_at":"2025-03-24T13:20:27.084Z","repository":{"id":95730486,"uuid":"133104549","full_name":"StevenMMortimer/squareupr","owner":"StevenMMortimer","description":"This R package connects the Square APIs from R","archived":false,"fork":false,"pushed_at":"2020-07-23T16:48:55.000Z","size":390,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-01-29T18:22:16.477Z","etag":null,"topics":["api","api-wrapper","r","square","squareup"],"latest_commit_sha":null,"homepage":"https://stevenmmortimer.github.io/squareupr/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StevenMMortimer.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-12T01:45:03.000Z","updated_at":"2019-08-15T18:37:13.000Z","dependencies_parsed_at":"2023-05-21T19:45:28.022Z","dependency_job_id":null,"html_url":"https://github.com/StevenMMortimer/squareupr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenMMortimer%2Fsquareupr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenMMortimer%2Fsquareupr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenMMortimer%2Fsquareupr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenMMortimer%2Fsquareupr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StevenMMortimer","download_url":"https://codeload.github.com/StevenMMortimer/squareupr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245276093,"owners_count":20588895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-wrapper","r","square","squareup"],"created_at":"2024-10-14T21:47:33.849Z","updated_at":"2025-03-24T13:20:27.055Z","avatar_url":"https://github.com/StevenMMortimer.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: \n  github_document:\n    html_preview: false\n---\n\n```{r, echo = FALSE, message = FALSE}\nknitr::opts_chunk$set(\n  fig.align = 'center',\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\")\n```\n\n# squareupr\u003cimg src=\"man/figures/squareupr.png\" width=\"120px\" align=\"right\" /\u003e\n\n[![Build Status](https://travis-ci.org/StevenMMortimer/squareupr.svg?branch=master)](https://travis-ci.org/StevenMMortimer/squareupr)\n[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/StevenMMortimer/squareupr?branch=master\u0026svg=true)](https://ci.appveyor.com/project/StevenMMortimer/squareupr)\n[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/squareupr)](http://cran.r-project.org/package=squareupr)\n[![Coverage Status](https://codecov.io/gh/StevenMMortimer/squareupr/branch/master/graph/badge.svg)](https://codecov.io/gh/StevenMMortimer/squareupr?branch=master)\n\n**squareupr** is an R package that connects to the Square APIs (Connect v1 \u0026 v2).\n\n  * OAuth 2.0 (Single sign-on) and Personal Access Token Authentication methods (`sq_auth()`)\n  * v2 Locations Endpoint (`sq_list_locations()`, `sq_get_location()`)\n  * v2 Transactions Endpoint (`sq_list_transactions()`, `sq_get_transaction()`)\n  * v2 Customers Endpoint - CRUD (Create, Retrieve, Update, Delete) methods for customers with: \n    * `sq_list_customers()`, `sq_search_customers()`, `sq_get_customer()`, `sq_create_customer()`, `sq_update_customer()`, `sq_delete_customer()`\n  * v1 Payments Endpoint (`sq_list_payments()`, `sq_get_payment()`)\n  * v1 Items Endpoint - CRUD (Create, Retrieve, Update, Delete) methods for items with: \n    * `sq_list_items()`, `sq_get_item()`, `sq_create_item()`, `sq_update_item()`, `sq_delete_item()`\n  * List v1 records (`sq_list_fees()`, `sq_list_categories()`, `sq_list_modifiers()`, \n`sq_list_discounts()`)\n\n## Table of Contents  \n  * [Installation](#installation)\n  * [Usage](#usage)\n    * [Authenticate](#authenticate)\n    * [Transactions](#transactions)\n    * [Customers](#customers)\n  * [Credits](#credits)\n  * [More Information](#more-information)\n\n## Installation\n\n```{r, eval = FALSE}\n# This package is not yet available on CRAN so you must install from GitHub\n# install.packages(\"devtools\")\ndevtools::install_github(\"StevenMMortimer/squareupr\")\n```\n\nIf you encounter a clear bug, please file a minimal reproducible example on \n[GitHub](https://github.com/StevenMMortimer/squareupr/issues).\n\n## Usage\n\n### Authenticate\nFirst, load the **squareupr** package and authenticate. There are two ways to authenticate:  \n\n  1. Personal Access Token\n  2. OAuth 2.0\n\n```{r auth, include = FALSE}\nlibrary(dplyr)\nlibrary(squareupr)\nsettings \u003c- readRDS(here::here(\"tests\", \"testthat\", \"squareupr_test_settings.rds\"))\nsuppressMessages(sq_auth(personal_access_token = settings$personal_access_token, \n                         verbose = FALSE))\n```\n\n```{r, eval=FALSE}\nlibrary(dplyr)\nlibrary(squareupr)\n\n# Using Personal Access Token (PAT)\nsq_auth(personal_access_token = \"sq-Th1s1sMyPers0nalAcessT0ken\")\n\n# Using OAuth 2.0 authentication\nsq_auth()\n```\n\nNOTE: Before using OAuth 2.0 authentication it is necessary that you set up your \nown Connected App in the Square dashboard. An App ID and App Secret will be \nprovided, then you will be able to plug into your script like so:\n\n```{r other-params, eval=FALSE}\noptions(squareupr.app_id = \"sq0-99-thisisatest99connected33app22id\")\noptions(squareupr.app_secret = \"sq0-Th1s1sMyAppS3cr3t\")\nsq_auth()\n```\n\nOAuth 2.0 credentials will be cached locally in a file entitled `\".httr-oauth-squareupr\"` \nin the current working directory so that a new token is not needed each session.\n\n### Transactions\nTransactions are organized by location. With the v2 Locations endpoint you can pull \ninformation regarding all locations first to obtain the location IDs. Then with the \n`sq_list_transactions()` function you can provide the location and timeframe to search. \nThe function defaults to pulling transactions from the previous day using `Sys.Date() - 1`. \nOnce you obtain the transactions the `tenders` field lists all methods of payment \nused to pay in the transaction.\n\n```{r transactions-by-location}\n# list all locations\nour_locations \u003c- sq_list_locations()\nour_transactions \u003c- sq_list_transactions(location = our_locations$id[2], \n                                         begin_time = as.Date('2019-07-09'), \n                                         end_time = as.Date('2019-07-10'))\nour_transactions\n```\n\n### Customers\nOnce you pull data about transactions you can take the customer_id from the transaction \n`tenders` field and match that up with customer details. In Square customers can \nbe placed into groups that allow for the analysis of transactions at a group-level.\n\n```{r customers}\n# list customers created in the last 30 days\ncreated_start \u003c- format(Sys.Date() - 30, '%Y-%m-%dT00:00:00-00:00')\ncreated_end \u003c- format(Sys.Date(), '%Y-%m-%dT00:00:00-00:00')\nour_customers \u003c- sq_search_customers(query = list(filter=\n                                                    list(created_at=\n                                                           list(start_at=created_start,\n                                                                end_at=created_end))))\nour_customers$given_name \u003c- \"{HIDDEN}\"\nour_customers$family_name \u003c- \"{HIDDEN}\"\nour_customers %\u003e% select(id, created_at, updated_at, \n                         given_name, family_name, preferences, groups)\n\n# show the groups that each customer belongs to\n# filter to the groups designated automatically by Square\nsq_extract_cust_groups(our_customers) %\u003e%\n  filter(grepl(\"^CQ689YH4KCJMY\", groups.id))\n```\n\n## Credits\nThis application uses other open source software components. The authentication \ncomponents are mostly verbatim copies of the routines established in the **googlesheets** \npackage (https://github.com/jennybc/googlesheets). We acknowledge and are grateful \nto these developers for their contributions to open source.\n\n## More Information\nThis package makes requests best formatted to match what the APIs require as input. \nThis articulation is not perfect and continued progress will be made to add and improve \nfunctionality. For details on formatting, attributes, and methods please refer to \n[Square's documentation](https://docs.connect.squareup.com/api/connect/v2) \nas they are explained better there.\n\nMore information is also available on the `pkgdown` site at \nhttps://StevenMMortimer.github.io/squareupr.  \n\n[Top](#squareupr)\n\n---\nPlease note that this project is released with a [Contributor Code of Conduct](CONDUCT.md).\nBy participating in this project you agree to abide by its terms.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevenmmortimer%2Fsquareupr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevenmmortimer%2Fsquareupr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevenmmortimer%2Fsquareupr/lists"}