{"action":"closed","issue":{"url":"https://api.github.com/repos/coopcycle/coopcycle-web/issues/374","repository_url":"https://api.github.com/repos/coopcycle/coopcycle-web","labels_url":"https://api.github.com/repos/coopcycle/coopcycle-web/issues/374/labels{/name}","comments_url":"https://api.github.com/repos/coopcycle/coopcycle-web/issues/374/comments","events_url":"https://api.github.com/repos/coopcycle/coopcycle-web/issues/374/events","html_url":"https://github.com/coopcycle/coopcycle-web/issues/374","id":330926396,"node_id":"MDU6SXNzdWUzMzA5MjYzOTY=","number":374,"title":"API endpoint to create deliveries for shop orders","user":{"login":"alexsegura","id":1162230,"node_id":"MDQ6VXNlcjExNjIyMzA=","avatar_url":"https://avatars1.githubusercontent.com/u/1162230?v=4","gravatar_id":"","url":"https://api.github.com/users/alexsegura","html_url":"https://github.com/alexsegura","followers_url":"https://api.github.com/users/alexsegura/followers","following_url":"https://api.github.com/users/alexsegura/following{/other_user}","gists_url":"https://api.github.com/users/alexsegura/gists{/gist_id}","starred_url":"https://api.github.com/users/alexsegura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexsegura/subscriptions","organizations_url":"https://api.github.com/users/alexsegura/orgs","repos_url":"https://api.github.com/users/alexsegura/repos","events_url":"https://api.github.com/users/alexsegura/events{/privacy}","received_events_url":"https://api.github.com/users/alexsegura/received_events","type":"User","site_admin":false},"labels":[{"id":958639386,"node_id":"MDU6TGFiZWw5NTg2MzkzODY=","url":"https://api.github.com/repos/coopcycle/coopcycle-web/labels/RFC","name":"RFC","color":"cc317c","default":false},{"id":959975732,"node_id":"MDU6TGFiZWw5NTk5NzU3MzI=","url":"https://api.github.com/repos/coopcycle/coopcycle-web/labels/WIP","name":"WIP","color":"fbca04","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-09T23:24:52Z","updated_at":"2018-08-02T16:08:19Z","closed_at":"2018-08-02T16:08:19Z","author_association":"MEMBER","body":"This is a proposal & an RFC to reintroduce an API endpoint to create deliveries. \r\nThere used to be such an endpoint, but right now deliveries are [read-only](https://github.com/coopcycle/coopcycle-web/blob/823643d2d1a561be898350faf2e1ff4a340272dd/src/AppBundle/Entity/Delivery.php#L17)\r\n\r\nThe goal is to allow external systems (i.e, an e-commerce website) to create deliveries\r\nThis way, merchants having an existing e-commerce website could delegate the shipping to a coop using CoopCycle \r\nAs an example, there is some draft work in [coopcycle-wp](https://github.com/coopcycle/coopcycle-wp) to add a CoopCycle Shipping Method in WooCommerce\r\n\r\n### General idea\r\n\r\nA `Store` in CoopCycle represents the external store. \r\nIt provides a user account to the store owner, and allows grabbing an API Token. \r\nWhen an API call is received with a Store token, it creates a `Delivery` with a pickup address corresponding to the store address defined in the back-office. \r\n\r\n### Authentication\r\n\r\nI'm not sure we can use JWT authentication as-is for those tokens, as they need to have a long TTL. \r\nMaybe we will need to use a custom token system & authenticator in Symfony Security?\r\n\r\n### Keep track of the external order\r\n\r\nI think we will need to keep track of the order on the external system. \r\nMaybe we could create a \"fake\" order in our system too?\r\n\r\n### JSON payload\r\n\r\nHere is an example of JSON payload \r\n\r\n```\r\nPOST /api/deliveries\r\n{\r\n  pickup: {\r\n    before: \"2018-06-08 12:00:00\"\r\n  }, \r\n  dropoff:  {\r\n    address: {\r\n      streetAddress: \"67, rue de la Sorbonne\", \r\n      firstName: \"Jane\",\r\n      lastName: \"Doe\", \r\n      telephone: \"+33612345678\"\r\n    },\r\n    before: \"2018-06-08 14:00:00\"\r\n  }, \r\n  order: {\r\n    code: \"00000001\"\r\n  }\r\n}\r\n```"}}
{"actor":{"display_login":"alexsegura"}}