Skip to content

Instantly share code, notes, and snippets.

@zzzsochi
Last active September 23, 2015 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zzzsochi/59e904bc1eb38c04d7f9 to your computer and use it in GitHub Desktop.
Save zzzsochi/59e904bc1eb38c04d7f9 to your computer and use it in GitHub Desktop.
Интеграция с TicketsCloud

Получение мероприятий

$ http --json -v GET https://dev.ticketscloud.org/v1/services/simple/events 'Authorization: key 05d8f493143d4496bdc5e516d1df37d0'
GET /v1/services/simple/events HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Authorization:  key 05d8f493143d4496bdc5e516d1df37d0
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Host: dev.ticketscloud.org
User-Agent: HTTPie/0.8.0



HTTP/1.1 200 OK
Cache-Control: private, max-age=0, no-cache, no-store
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=UTF-8
Date: Tue, 22 Sep 2015 20:52:52 GMT
Server: nginx/1.6.2
Transfer-Encoding: chunked
X-Partner: 5601bdfdf06c5a7c0b721e53

[
    {
        "id": "5601bd39f06c5a7c0c721e37",
        "age_rating": 0,
        "created_at": "2015-09-22T20:42:33.468000+00:00",
        "deal": {
            "extra": "10.0%",
            "pfc": false
        },
        "lifetime": "BEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20160610T000000Z\r\nDTEND;VALUE=DATE-TIME:20160612T235900Z\r\nEND:VEVENT\r\n",
        "map": null,
        "media": {
            "cover": {
                "author": "5601bb6ff06c5a7c0b721e30",
                "content_type": "image/jpeg",
                "id": "5601bd39f06c5a7c0c721e38",
                "length": 20429,
                "md5hash": "ce15a701d11384d6b9714af124546834",
                "url": "https://s3-eu-west-1.amazonaws.com:443/media.ticketscloud/develop/image/2015-09/5601bd39f06c5a7c0c721e38.jpg"
            },
            "cover_original": {
                "author": "5601bb6ff06c5a7c0b721e30",
                "content_type": "image/jpeg",
                "id": "5601bd39f06c5a7c0b721e3b",
                "length": 15005,
                "md5hash": "f33fe052fe8ce7765c5ae3ba6ef27d20",
                "url": "https://s3-eu-west-1.amazonaws.com:443/media.ticketscloud/develop/image/2015-09/5601bd39f06c5a7c0b721e3b.jpg"
            },
            "cover_small": {
                "author": "5601bb6ff06c5a7c0b721e30",
                "content_type": "image/jpeg",
                "id": "5601bd3af06c5a7c0b721e3c",
                "length": 29485,
                "md5hash": "0787af063b4031dbd9e4af930a3d3968",
                "url": "https://s3-eu-west-1.amazonaws.com:443/media.ticketscloud/develop/image/2015-09/5601bd3af06c5a7c0b721e3c.jpg"
            }
        },
        "org": {
            "contact": {
                "address": "kjbjljkbk",
                "email": "org@nashe.ru",
                "name": "",
                "phones": [
                    "79032679888"
                ],
                "www": ""
            },
            "desc": "жыулофаь",
            "id": "5601bb6ff06c5a7c0b721e30",
            "media": {},
            "name": "Нашерадио",
            "tags": []
        },
        "sets": [
            {
                "id": "5601bd64f06c5a7c0c721e3d",
                "amount": 10000,
                "amount_vacant": 10000,
                "name": "Входной",
                "price": "2200.0",
                "price_extra": "200.0",
                "price_org": "2000.00",
                "rules": [
                    {
                        "cal": "BEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20150921T210000Z\r\nDTEND;VALUE=DATE-TIME:20160101T205900Z\r\nEND:VEVENT\r\n",
                        "current": true,
                        "id": "5601bd64f06c5a7c0c721e39",
                        "price": "2200.0",
                        "price_extra": "200.0",
                        "price_org": "2000.00"
                    },
                    {
                        "cal": "BEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20160101T210000Z\r\nDTEND;VALUE=DATE-TIME:20160301T205900Z\r\nEND:VEVENT\r\n",
                        "current": false,
                        "id": "5601bd64f06c5a7c0c721e3a",
                        "price": "3300.0",
                        "price_extra": "300.0",
                        "price_org": "3000.00"
                    }
                ],
                "sector": null
            },
            {
                "id": "5601bd87f06c5a7c0c721e4e",
                "amount": 5000,
                "amount_vacant": 5000,
                "name": "VIP",
                "price": "5500.0",
                "price_extra": "500.0",
                "price_org": "5000.00",
                "rules": [
                    {
                        "id": "5601bd87f06c5a7c0c721e4a",
                        "cal": "BEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20150921T210000Z\r\nDTEND;VALUE=DATE-TIME:20160101T205900Z\r\nEND:VEVENT\r\n",
                        "current": true,
                        "price": "5500.0",
                        "price_extra": "500.0",
                        "price_org": "5000.00"
                    },
                    {
                        "id": "5601bd87f06c5a7c0c721e4b",
                        "cal": "BEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20160101T210000Z\r\nDTEND;VALUE=DATE-TIME:20160301T205900Z\r\nEND:VEVENT\r\n",
                        "current": false,
                        "price": "7700.0",
                        "price_extra": "700.0",
                        "price_org": "7000.00"
                    }
                ],
                "sector": null
            }
        ],
        "status": "public",
        "tags": [
            "фестивали"
        ],
        "ticket_template": null,
        "tickets_amount": 15000,
        "tickets_amount_vacant": 15000,
        "title": {
            "desc": "«Наше́ствие» — один из крупнейших в СНГ фестивалей мультиформатной отечественной музыки под открытым небом.",
            "text": "Нашествие 2016"
        },
        "updated_at": "2015-09-22T20:46:33.359000+00:00",
        "venue": {
            "id": "5601bd24f06c5a7c0b721e3a",
            "address": "ул. Строителей, 15, Конаково, Тверская обл., Россия, 171256",
            "city": {
                "country": "RU",
                "id": 545673,
                "name": {
                    "be": "Горад Канакова",
                    "default": "Konakovo",
                    "en": "Konakovo",
                    "ru": "Конаково",
                    "zh": "科納科沃"
                },
                "timezone": "Europe/Moscow"
            },
            "country": {
                "id": "RU",
                "name": {
                    "be": "Расійская Федэрацыя",
                    "default": "Russia",
                    "en": "Russia",
                    "fr": "Russie",
                    "ru": "Россия",
                    "zh": "俄罗斯"
                }
            },
            "desc": null,
            "name": "Територия Фетиваля Нашествие",
            "point": {
                "coordinates": [
                    36.774115562438965,
                    56.69642411841998
                ],
                "type": "Point"
            }
        }
    }
]

Создание заказа

$ http --json -v POST 'https://dev.ticketscloud.org/v1/resources/orders?fields-schema=id,number,created_at,reserved_till,status,value,payment,tickets{id,serial,number,barcode}' 'Authorization:key 05d8f493143d4496bdc5e516d1df37d0' 'payment:={"system": "api/BASE"}' 'event=5601bd39f06c5a7c0c721e37' 'random:={"5601bd64f06c5a7c0c721e3d": 2, "5601bd87f06c5a7c0c721e4e": 1}'
POST /v1/resources/orders?fields-schema=id,number,created_at,reserved_till,status,value,payment,tickets%7Bid,serial,number,barcode%7D HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Authorization: key 05d8f493143d4496bdc5e516d1df37d0
Connection: keep-alive
Content-Length: 146
Content-Type: application/json; charset=utf-8
Host: dev.ticketscloud.org
User-Agent: HTTPie/0.8.0

{
    "event": "5601bd39f06c5a7c0c721e37",
    "payment": {
        "system": "api/BASE"
    },
    "random": {
        "5601bd64f06c5a7c0c721e3d": 2,
        "5601bd87f06c5a7c0c721e4e": 1
    }
}

HTTP/1.1 201 Created
Cache-Control: private, max-age=0, no-cache, no-store
Connection: keep-alive
Content-Length: 588
Content-Type: application/json; charset=UTF-8
Date: Tue, 22 Sep 2015 21:21:15 GMT
Server: nginx/1.6.2
X-Partner: 5601bdfdf06c5a7c0b721e53

{
    "id": "5601c64bf06c5a7c0c721eb0",
    "created_at": "2015-09-22T21:21:15.541000+00:00",
    "number": 17797,
    "payment": {
        "failure_url": null,
        "redirect_url": null,
        "success_url": null,
        "system": "5544f3e6f06c5a7a07ea77aa"
    },
    "reserved_till": "2015-09-22T21:31:15.576000+00:00",
    "status": "executed",
    "tickets": [
        {
            "id": "5601bd64f06c5a7c5eb2593e",
            "barcode": null,
            "number": 112141,
            "serial": "BKO"
        },
        {
            "id": "5601bd87f06c5a7c5eb28055",
            "barcode": null,
            "number": 110002,
            "serial": "EKX"
        },
        {
            "id": "5601bd64f06c5a7c5eb2593d",
            "barcode": null,
            "number": 112140,
            "serial": "BKO"
        }
    ],
    "value": "9900.00"
}

Изменение заказа

$ http --json -v PATCH 'https://dev.ticketscloud.org/v1/resources/orders/5601c64bf06c5a7c0c721eb0?fields-schema=id,number,created_at,reserved_till,status,value,payment,tickets{id,serial,number,barcode}' 'Authorization:key 05d8f493143d4496bdc5e516d1df37d0' 'random:={"5601bd64f06c5a7c0c721e3d": 1, "5601bd87f06c5a7c0c721e4e": 2}'
PATCH /v1/resources/orders/5601c64bf06c5a7c0c721eb0?fields-schema=id,number,created_at,reserved_till,status,value,payment,tickets%7Bid,serial,number,barcode%7D HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Authorization: key 05d8f493143d4496bdc5e516d1df37d0
Connection: keep-alive
Content-Length: 74
Content-Type: application/json; charset=utf-8
Host: dev.ticketscloud.org
User-Agent: HTTPie/0.8.0

{
    "random": {
        "5601bd64f06c5a7c0c721e3d": 1,
        "5601bd87f06c5a7c0c721e4e": 2
    }
}

HTTP/1.1 200 OK
Cache-Control: private, max-age=0, no-cache, no-store
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=UTF-8
Date: Tue, 22 Sep 2015 21:22:09 GMT
Server: nginx/1.6.2
Transfer-Encoding: chunked
X-Partner: 5601bdfdf06c5a7c0b721e53

{
    "created_at": "2015-09-22T21:21:15.541000+00:00",
    "id": "5601c64bf06c5a7c0c721eb0",
    "number": 17797,
    "payment": {
        "failure_url": null,
        "redirect_url": null,
        "success_url": null,
        "system": "5544f3e6f06c5a7a07ea77aa"
    },
    "reserved_till": "2015-09-22T21:31:15.576000+00:00",
    "status": "executed",
    "tickets": [
        {
            "barcode": null,
            "id": "5601bd64f06c5a7c5eb2593e",
            "number": 112141,
            "serial": "BKO"
        },
        {
            "barcode": null,
            "id": "5601bd87f06c5a7c5eb28055",
            "number": 110002,
            "serial": "EKX"
        },
        {
            "barcode": null,
            "id": "5601bd87f06c5a7c5eb28056",
            "number": 110003,
            "serial": "EKX"
        }
    ],
    "value": "13200.00"
}

Ожидание оплаты

$ http --json -v PATCH 'https://dev.ticketscloud.org/v1/resources/orders/5601c64bf06c5a7c0c721eb0?fields-schema=id,number,created_at,reserved_till,status,value,payment,tickets{id,serial,number,barcode}' 'Authorization:key 05d8f493143d4496bdc5e516d1df37d0' 'status=in_progress'
PATCH /v1/resources/orders/5601c64bf06c5a7c0c721eb0?fields-schema=id,number,created_at,reserved_till,status,value,payment,tickets%7Bid,serial,number,barcode%7D HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Authorization: key 05d8f493143d4496bdc5e516d1df37d0
Connection: keep-alive
Content-Length: 25
Content-Type: application/json; charset=utf-8
Host: dev.ticketscloud.org
User-Agent: HTTPie/0.8.0

{
    "status": "in_progress"
}

HTTP/1.1 200 OK
Cache-Control: private, max-age=0, no-cache, no-store
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=UTF-8
Date: Tue, 22 Sep 2015 21:22:41 GMT
Server: nginx/1.6.2
Transfer-Encoding: chunked
X-Partner: 5601bdfdf06c5a7c0b721e53

{
    "created_at": "2015-09-22T21:21:15.541000+00:00",
    "id": "5601c64bf06c5a7c0c721eb0",
    "number": 17797,
    "payment": {
        "failure_url": null,
        "redirect_url": null,
        "success_url": null,
        "system": "5544f3e6f06c5a7a07ea77aa"
    },
    "reserved_till": "2015-09-23T09:22:41.224000+00:00",
    "status": "in_progress",
    "tickets": [
        {
            "barcode": "41665553637146152",
            "id": "5601bd87f06c5a7c5eb28056",
            "number": 110003,
            "serial": "EKX"
        },
        {
            "barcode": "68775351692813264",
            "id": "5601bd87f06c5a7c5eb28055",
            "number": 110002,
            "serial": "EKX"
        },
        {
            "barcode": "59743619581965453",
            "id": "5601bd64f06c5a7c5eb2593e",
            "number": 112141,
            "serial": "BKO"
        }
    ],
    "value": "13200.00"
}

Подтверждение оплаты

$ http --json -v PATCH 'https://dev.ticketscloud.org/v1/resources/orders/5601c64bf06c5a7c0c721eb0?fields-schema=id,number,created_at,reserved_till,status,value,payment,tickets{id,serial,number,barcode}' 'Authorization:key 05d8f493143d4496bdc5e516d1df37d0' 'status=done'
PATCH /v1/resources/orders/5601c64bf06c5a7c0c721eb0?fields-schema=id,number,created_at,reserved_till,status,value,payment,tickets%7Bid,serial,number,barcode%7D HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Authorization: key 05d8f493143d4496bdc5e516d1df37d0
Connection: keep-alive
Content-Length: 18
Content-Type: application/json; charset=utf-8
Host: dev.ticketscloud.org
User-Agent: HTTPie/0.8.0

{
    "status": "done"
}

HTTP/1.1 200 OK
Cache-Control: private, max-age=0, no-cache, no-store
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=UTF-8
Date: Tue, 22 Sep 2015 21:22:56 GMT
Server: nginx/1.6.2
Transfer-Encoding: chunked
X-Partner: 5601bdfdf06c5a7c0b721e53

{
    "created_at": "2015-09-22T21:21:15.541000+00:00",
    "id": "5601c64bf06c5a7c0c721eb0",
    "number": 17797,
    "payment": {
        "failure_url": null,
        "redirect_url": null,
        "success_url": null,
        "system": "5544f3e6f06c5a7a07ea77aa"
    },
    "reserved_till": "2015-09-23T09:22:41.224000+00:00",
    "status": "done",
    "tickets": [
        {
            "barcode": "41665553637146152",
            "id": "5601bd87f06c5a7c5eb28056",
            "number": 110003,
            "serial": "EKX"
        },
        {
            "barcode": "68775351692813264",
            "id": "5601bd87f06c5a7c5eb28055",
            "number": 110002,
            "serial": "EKX"
        },
        {
            "barcode": "59743619581965453",
            "id": "5601bd64f06c5a7c5eb2593e",
            "number": 112141,
            "serial": "BKO"
        }
    ],
    "value": "13200.00"
}
@koorgoo
Copy link

koorgoo commented Sep 23, 2015

@zzzsochi, в самом начале сделай ссылку на инструкцию по установке http - https://github.com/jkbrzt/httpie#installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment