add an example for subscribing to RE 7 via Line ID
This commit is contained in:
parent
5c6523d7a2
commit
e3b26d46c5
3 changed files with 210 additions and 0 deletions
56
zuginfo_playbooks/subscription/zuginfo_api_subscribe_re7.yml
Normal file
56
zuginfo_playbooks/subscription/zuginfo_api_subscribe_re7.yml
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: "Zuginfo.nrw API"
|
||||||
|
hosts: localhost
|
||||||
|
vars:
|
||||||
|
unix_time_millis: "1762342729099"
|
||||||
|
lineid: "90407" # RE 7
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Account data
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
account: "{{ lookup('ansible.builtin.file','account.txt') | from_yaml }}"
|
||||||
|
|
||||||
|
- name: Set variables
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
aid: "{{ account.account.aid }}"
|
||||||
|
mysterious_id: "{{ account.account.mysterious_id }}"
|
||||||
|
user_id: "{{ account.account.user_id }}"
|
||||||
|
mysterious_id: "{{ account.account.mysterious_id }}"
|
||||||
|
|
||||||
|
- name: "Subscribe to info for RE 7"
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "https://www.zuginfo.nrw/gate/?requestId={{ mysterious_id }}&hciMethod=SubscrCreate&hciVersion=1.24&hciClientType=WEB&hciClientVersion=10104&aid={{ aid }}&rnd={{ unix_time_millis }}"
|
||||||
|
method: POST
|
||||||
|
body: "{{ lookup('ansible.builtin.template','subscription_line_id.json.j2') }}"
|
||||||
|
headers:
|
||||||
|
Accept-Encoding: gzip, deflate, br, zstd
|
||||||
|
Content-Type: application/json
|
||||||
|
Origin: https://www.zuginfo.nrw/
|
||||||
|
Referer: https://www.zuginfo.nrw/
|
||||||
|
TE: trailers
|
||||||
|
register: subscribe_re7
|
||||||
|
|
||||||
|
- name: "Print Result: Subscribe to RE 7"
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ subscribe_re7 }}"
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
subscription_id: "{{ subscribe_re7.json.svcResL[0].res.subscrId }}"
|
||||||
|
|
||||||
|
- name: "Verify Subscription"
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "https://www.zuginfo.nrw/gate/?requestId={{ mysterious_id }}&hciMethod=SubscrDetails&hciVersion=1.24&hciClientType=WEB&hciClientVersion=10104&aid={{ aid }}&rnd={{ unix_time_millis }}"
|
||||||
|
method: POST
|
||||||
|
body: "{{ lookup('ansible.builtin.template','verify_subscription.json.j2') }}"
|
||||||
|
headers:
|
||||||
|
Accept-Encoding: gzip, deflate, br, zstd
|
||||||
|
Content-Type: application/json
|
||||||
|
Origin: https://www.zuginfo.nrw/
|
||||||
|
Referer: https://www.zuginfo.nrw/
|
||||||
|
TE: trailers
|
||||||
|
register: verify_subscription
|
||||||
|
|
||||||
|
- name: "Print Result: Verify Subscription"
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ verify_subscription }}"
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
{
|
||||||
|
"id": "{{ mysterious_id }}",
|
||||||
|
"ver": "1.24",
|
||||||
|
"lang": "deu",
|
||||||
|
"auth": {
|
||||||
|
"type": "AID",
|
||||||
|
"aid": "{{ aid }}"
|
||||||
|
},
|
||||||
|
"client": {
|
||||||
|
"id": "HAFAS",
|
||||||
|
"type": "WEB",
|
||||||
|
"name": "webapp",
|
||||||
|
"l": "vs_webapp",
|
||||||
|
"v": 10104
|
||||||
|
},
|
||||||
|
"formatted": false,
|
||||||
|
"ext": "VRR.1",
|
||||||
|
"svcReqL": [
|
||||||
|
{
|
||||||
|
"meth": "SubscrCreate",
|
||||||
|
"req": {
|
||||||
|
"statSubscr": {
|
||||||
|
"hysteresis": {
|
||||||
|
"himFltrL": [
|
||||||
|
{
|
||||||
|
"type": "HIMCAT",
|
||||||
|
"mode": "INC",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "HIMCAT",
|
||||||
|
"mode": "INC",
|
||||||
|
"value": "4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "HIMCAT",
|
||||||
|
"mode": "INC",
|
||||||
|
"value": "2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "HIMCAT",
|
||||||
|
"mode": "INC",
|
||||||
|
"value": "3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "HIMCAT",
|
||||||
|
"mode": "INC",
|
||||||
|
"value": "1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"jnyFltrL": [
|
||||||
|
{
|
||||||
|
"type": "LINEID",
|
||||||
|
"mode": "INC",
|
||||||
|
"value": {{ line_id }}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"serviceDays": {
|
||||||
|
"selectedWeekdays": "1111111",
|
||||||
|
"beginDate": "20250615",
|
||||||
|
"endDate": "20331211",
|
||||||
|
"beginTime": "000000",
|
||||||
|
"endTime": "235959"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userId": "{{ user_id }}",
|
||||||
|
"channels": [
|
||||||
|
{
|
||||||
|
"channelId": "{{ channel_id }}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"id": "1|5|"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
{
|
||||||
|
"id": "{{ mysterious_id }}",
|
||||||
|
"ver": "1.24",
|
||||||
|
"lang": "deu",
|
||||||
|
"auth": {
|
||||||
|
"type": "AID",
|
||||||
|
"aid": "{{ aid }}"
|
||||||
|
},
|
||||||
|
"client": {
|
||||||
|
"id": "HAFAS",
|
||||||
|
"type": "WEB",
|
||||||
|
"name": "webapp",
|
||||||
|
"l": "vs_webapp",
|
||||||
|
"v": 10104
|
||||||
|
},
|
||||||
|
"formatted": false,
|
||||||
|
"ext": "VRR.1",
|
||||||
|
"svcReqL": [
|
||||||
|
{
|
||||||
|
"meth": "SubscrCreate",
|
||||||
|
"req": {
|
||||||
|
"statSubscr": {
|
||||||
|
"hysteresis": {
|
||||||
|
"himFltrL": [
|
||||||
|
{
|
||||||
|
"type": "HIMCAT",
|
||||||
|
"mode": "INC",
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "HIMCAT",
|
||||||
|
"mode": "INC",
|
||||||
|
"value": "4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "HIMCAT",
|
||||||
|
"mode": "INC",
|
||||||
|
"value": "2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "HIMCAT",
|
||||||
|
"mode": "INC",
|
||||||
|
"value": "3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "HIMCAT",
|
||||||
|
"mode": "INC",
|
||||||
|
"value": "1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"jnyFltrL": [
|
||||||
|
{
|
||||||
|
"type": "LINEID",
|
||||||
|
"mode": "INC",
|
||||||
|
"value": 90407
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"serviceDays": {
|
||||||
|
"selectedWeekdays": "1111111",
|
||||||
|
"beginDate": "20250615",
|
||||||
|
"endDate": "20331211",
|
||||||
|
"beginTime": "000000",
|
||||||
|
"endTime": "235959"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userId": "{{ user_id }}",
|
||||||
|
"channels": [
|
||||||
|
{
|
||||||
|
"channelId": "{{ channel_id }}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"id": "1|5|"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue