{"_id":"58112e73ded0340f0085d077","parentDoc":null,"version":{"_id":"58112e71ded0340f0085d02a","project":"551e85be610f400d00837db7","__v":4,"createdAt":"2016-10-26T22:30:09.862Z","releaseDate":"2016-10-26T22:30:09.862Z","categories":["58112e72ded0340f0085d02b","58112e72ded0340f0085d02c","58112e72ded0340f0085d02d","58112e72ded0340f0085d02e","58112e72ded0340f0085d02f","58112e72ded0340f0085d030","58112e72ded0340f0085d031","58112e72ded0340f0085d032","58112e72ded0340f0085d033","58112e72ded0340f0085d034","581137cc604d3c230048b7e4","58dc367221742d0f00a73f98","590768e54669da0f00db5c0b"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"new designer","version_clean":"2.0.0","version":"2.0"},"__v":0,"project":"551e85be610f400d00837db7","user":"55253acaf0f4610d00f7193f","category":{"_id":"58112e72ded0340f0085d030","version":"58112e71ded0340f0085d02a","project":"551e85be610f400d00837db7","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-09-25T20:14:44.667Z","from_sync":false,"order":4,"slug":"store-api-methods","title":"Store API Methods"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-10-22T16:05:41.672Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":6,"body":"_Methods for getting [Address](doc:customeraddress) data for a customer from the Store API._\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    \\t\\t/v1/store/api/customer/addresses/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    /v1/store/api/customer/addresses/{address_id}/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method put\\\">PUT</span>\\n  <span class=\\\"uri\\\">\\n    /v1/store/api/customer/addresses/{address_id}/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method post\\\">POST</span>\\n  <span class=\\\"uri\\\">\\n    /v1/store/api/customer/addresses/\\n  </span>\\n</div>\"\n}\n[/block]\n# Get all customer addresses\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.get('/v1/store/api/customer/addresses/');\",\n      \"language\": \"javascript\",\n      \"name\": \"List\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"count\\\": 1,\\n  \\\"next\\\": null,\\n  \\\"prev\\\": null,\\n  \\\"results\\\": [{\\n    \\\"city\\\": \\\"austin\\\",\\n    \\\"company\\\": \\\"\\\",\\n    \\\"country\\\": \\\"US\\\",\\n    \\\"id\\\": 39161778,\\n    \\\"phone_number\\\": \\\"\\\",\\n    \\\"state\\\": \\\"TX\\\",\\n    \\\"status\\\": 2,\\n    \\\"status_message\\\": \\\"Address Not Found.  \\\",\\n    \\\"street\\\": \\\"352135 Solid Ln.\\\",\\n    \\\"to\\\": \\\"Blake Messer\\\",\\n    \\\"type\\\": \\\"address\\\",\\n    \\\"unit\\\": \\\"\\\",\\n    \\\"url\\\": \\\"/v1/store/api/customer/addresses/39161778/\\\",\\n    \\\"zip_code\\\": \\\"78704\\\"\\n  }]\\n}\",\n      \"language\": \"javascript\",\n      \"name\": \"200 OK\"\n    }\n  ]\n}\n[/block]\n# Get an address\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n\\t\\t/v1/store/api/addresses/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.get('/v1/store/api/addresses/39161778/');\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"city\\\": \\\"austin\\\",\\n    \\\"company\\\": \\\"\\\",\\n    \\\"country\\\": \\\"US\\\",\\n    \\\"id\\\": 39161778,\\n    \\\"phone_number\\\": \\\"\\\",\\n    \\\"state\\\": \\\"TX\\\",\\n    \\\"status\\\": 2,\\n    \\\"status_message\\\": \\\"Address Not Found.  \\\",\\n    \\\"street\\\": \\\"352135 Solid Ln.\\\",\\n    \\\"to\\\": \\\"Blake Messer\\\",\\n    \\\"type\\\": \\\"address\\\",\\n    \\\"unit\\\": \\\"\\\",\\n    \\\"url\\\": \\\"/v1/store/api/customer/addresses/39161778/\\\",\\n    \\\"zip_code\\\": \\\"78704\\\"\\n  }\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nPUT:\nAddresses are immutable. When you make a PUT request to change address 1, note that the response will be the data of the old address + your changes with the a new id (2). Address 1 will be deleted in the database and no longer accessible via the API.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n\\ttype: 'PUT',\\n\\turl: '/v1/store/api/customer/addresses/1/',\\n\\tdataType: 'json',\\n\\tcontentType: \\\"application/json;\\\",\\n\\tdata: JSON.stringify({'to': 'New Person', 'street': '123 New St'})\\n})\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  city: \\\"Austin\\\"\\n\\tcompany: \\\"\\\"\\n\\tcountry: \\\"US\\\"\\n  deleted_at: null\\n  icon: \\\"United-States.png\\\"\\n  id: 2\\n  phone_number: \\\"\\\"\\n  state: \\\"TX\\\"\\n  status: 0\\n  status_message: null\\n  street: \\\"123 New St\\\"\\n  to: \\\"New Person\\\"\\n  type: \\\"address\\\"\\n  unit: \\\"30\\\"\\n  zip_code: \\\"78701\\\"\\n}\\n\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n\\ttype: 'POST',\\n\\turl: '/v1/store/api/customer/addresses/',\\n\\tdataType: 'json',\\n\\tcontentType: \\\"application/json\\\",\\n\\tdata: JSON.stringify({\\n\\t\\t'to': 'New Person',\\n\\t\\t'street': '123 New St',\\n\\t\\t'city': 'Austin',\\n\\t\\t'state': 'TX',\\n\\t\\t'zip_code': '012345',\\n\\t\\t'country': 'US'\\n\\t})\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  city: \\\"Austin\\\"\\n  company: null\\n  country: \\\"US\\\"\\n  deleted_at: null\\n  icon: \\\"United-States.png\\\"\\n  id: 3\\n  phone_number: null\\n  state: \\\"TX\\\"\\n  status: 0\\n  status_message: null\\n  street: \\\"123 New St\\\"\\n  to: \\\"New Person\\\"\\n  type: \\\"address\\\"\\n  unit: null\\n  zip_code: \\\"012345\\\"\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({\\n\\ttype: 'DELETE',\\n\\turl: '/v1/store/api/customer/addresses/3/',\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nA DELETE will return the address object with the timestamp it was deleted in the deleted_at column\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  city: \\\"Austin\\\"\\n  company: null\\n  country: \\\"US\\\"\\n  deleted_at: \\\"Fri, 15 Jan 2016 23:30:45 GMT\\\"\\n  icon: \\\"United-States.png\\\"\\n  id: 3\\n  phone_number: null\\n  state: \\\"TX\\\"\\n  status: 0\\n  status_message: null\\n  street: \\\"123 New St\\\"\\n  to: \\\"New Person\\\"\\n  type: \\\"address\\\"\\n  unit: null\\n  zip_code: \\\"012345\\\"\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"address-methods","type":"basic","title":"Address Methods"}
_Methods for getting [Address](doc:customeraddress) data for a customer from the Store API._ [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n \t\t/v1/store/api/customer/addresses/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n /v1/store/api/customer/addresses/{address_id}/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method put\">PUT</span>\n <span class=\"uri\">\n /v1/store/api/customer/addresses/{address_id}/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method post\">POST</span>\n <span class=\"uri\">\n /v1/store/api/customer/addresses/\n </span>\n</div>" } [/block] # Get all customer addresses [block:code] { "codes": [ { "code": "$.get('/v1/store/api/customer/addresses/');", "language": "javascript", "name": "List" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"count\": 1,\n \"next\": null,\n \"prev\": null,\n \"results\": [{\n \"city\": \"austin\",\n \"company\": \"\",\n \"country\": \"US\",\n \"id\": 39161778,\n \"phone_number\": \"\",\n \"state\": \"TX\",\n \"status\": 2,\n \"status_message\": \"Address Not Found. \",\n \"street\": \"352135 Solid Ln.\",\n \"to\": \"Blake Messer\",\n \"type\": \"address\",\n \"unit\": \"\",\n \"url\": \"/v1/store/api/customer/addresses/39161778/\",\n \"zip_code\": \"78704\"\n }]\n}", "language": "javascript", "name": "200 OK" } ] } [/block] # Get an address [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n\t\t/v1/store/api/addresses/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.get('/v1/store/api/addresses/39161778/');", "language": "javascript" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"city\": \"austin\",\n \"company\": \"\",\n \"country\": \"US\",\n \"id\": 39161778,\n \"phone_number\": \"\",\n \"state\": \"TX\",\n \"status\": 2,\n \"status_message\": \"Address Not Found. \",\n \"street\": \"352135 Solid Ln.\",\n \"to\": \"Blake Messer\",\n \"type\": \"address\",\n \"unit\": \"\",\n \"url\": \"/v1/store/api/customer/addresses/39161778/\",\n \"zip_code\": \"78704\"\n }", "language": "javascript" } ] } [/block] PUT: Addresses are immutable. When you make a PUT request to change address 1, note that the response will be the data of the old address + your changes with the a new id (2). Address 1 will be deleted in the database and no longer accessible via the API. [block:code] { "codes": [ { "code": "$.ajax({\n\ttype: 'PUT',\n\turl: '/v1/store/api/customer/addresses/1/',\n\tdataType: 'json',\n\tcontentType: \"application/json;\",\n\tdata: JSON.stringify({'to': 'New Person', 'street': '123 New St'})\n})", "language": "javascript" } ] } [/block] [block:code] { "codes": [ { "code": "{\n city: \"Austin\"\n\tcompany: \"\"\n\tcountry: \"US\"\n deleted_at: null\n icon: \"United-States.png\"\n id: 2\n phone_number: \"\"\n state: \"TX\"\n status: 0\n status_message: null\n street: \"123 New St\"\n to: \"New Person\"\n type: \"address\"\n unit: \"30\"\n zip_code: \"78701\"\n}\n", "language": "javascript" } ] } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n\ttype: 'POST',\n\turl: '/v1/store/api/customer/addresses/',\n\tdataType: 'json',\n\tcontentType: \"application/json\",\n\tdata: JSON.stringify({\n\t\t'to': 'New Person',\n\t\t'street': '123 New St',\n\t\t'city': 'Austin',\n\t\t'state': 'TX',\n\t\t'zip_code': '012345',\n\t\t'country': 'US'\n\t})\n});", "language": "javascript" } ] } [/block] [block:code] { "codes": [ { "code": "{\n city: \"Austin\"\n company: null\n country: \"US\"\n deleted_at: null\n icon: \"United-States.png\"\n id: 3\n phone_number: null\n state: \"TX\"\n status: 0\n status_message: null\n street: \"123 New St\"\n to: \"New Person\"\n type: \"address\"\n unit: null\n zip_code: \"012345\"\n}", "language": "javascript" } ] } [/block] [block:code] { "codes": [ { "code": "$.ajax({\n\ttype: 'DELETE',\n\turl: '/v1/store/api/customer/addresses/3/',\n});", "language": "javascript" } ] } [/block] A DELETE will return the address object with the timestamp it was deleted in the deleted_at column [block:code] { "codes": [ { "code": "{\n city: \"Austin\"\n company: null\n country: \"US\"\n deleted_at: \"Fri, 15 Jan 2016 23:30:45 GMT\"\n icon: \"United-States.png\"\n id: 3\n phone_number: null\n state: \"TX\"\n status: 0\n status_message: null\n street: \"123 New St\"\n to: \"New Person\"\n type: \"address\"\n unit: null\n zip_code: \"012345\"\n}", "language": "javascript" } ] } [/block]