| 870 | } |
| 871 | |
| 872 | static void json_add_recurrence(struct json_stream *js, |
| 873 | const char *fieldname, |
| 874 | const struct recurrence *offer_recurrence, |
| 875 | const struct recurrence_paywindow *offer_recurrence_paywindow, |
| 876 | const u32 *offer_recurrence_limit, |
| 877 | const struct recurrence_base *offer_recurrence_base, |
| 878 | bool compulsory) |
| 879 | { |
| 880 | const char *name; |
| 881 | json_object_start(js, fieldname); |
| 882 | json_add_bool(js, "compulsory_field", compulsory); |
| 883 | json_add_num(js, "time_unit", offer_recurrence->time_unit); |
| 884 | name = recurrence_time_unit_name(offer_recurrence->time_unit); |
| 885 | if (name) |
| 886 | json_add_string(js, "time_unit_name", name); |
| 887 | json_add_num(js, "period", offer_recurrence->period); |
| 888 | if (offer_recurrence_base) { |
| 889 | json_add_u64(js, "basetime", |
| 890 | offer_recurrence_base->basetime); |
| 891 | if (offer_recurrence_base->proportional_amount) |
| 892 | json_add_bool(js, "proportional_amount", true); |
| 893 | } |
| 894 | if (offer_recurrence_limit) |
| 895 | json_add_u32(js, "limit", *offer_recurrence_limit); |
| 896 | if (offer_recurrence_paywindow) { |
| 897 | json_object_start(js, "paywindow"); |
| 898 | json_add_u32(js, "seconds_before", |
| 899 | offer_recurrence_paywindow->seconds_before); |
| 900 | json_add_u32(js, "seconds_after", |
| 901 | offer_recurrence_paywindow->seconds_after); |
| 902 | json_object_end(js); |
| 903 | } |
| 904 | json_object_end(js); |
| 905 | } |
| 906 | |
| 907 | static bool json_add_offer_fields(struct command *cmd, |
| 908 | struct json_stream *js, |
no test coverage detected