this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

:bug: query params are optional

+28 -9
+28 -9
src/web/controllers/payment_controller.gleam
··· 57 57 wisp.no_content() 58 58 } 59 59 60 + fn get_all_payments_response( 61 + default: count_provider.CountProvider, 62 + fallback: count_provider.CountProvider, 63 + ) -> json.Json { 64 + [ 65 + #("default", count_provider.to_json(default)), 66 + #("fallback", count_provider.to_json(fallback)), 67 + ] 68 + |> json.object 69 + } 70 + 60 71 pub fn get_all_payments( 61 72 req: wisp.Request, 62 73 ctx: server.Context, ··· 74 85 75 86 use <- bool.guard( 76 87 when: !dict.has_key(params, "from"), 77 - return: wisp.bad_request() 78 - |> wisp.json_body(string_tree.from_string("Needs query params 'from'")), 88 + return: wisp.ok() 89 + |> wisp.json_body( 90 + get_all_payments_response( 91 + count_provider.new("default"), 92 + count_provider.new("fallback"), 93 + ) 94 + |> json.to_string_tree, 95 + ), 79 96 ) 80 97 81 98 use <- bool.guard( 82 99 when: !dict.has_key(params, "to"), 83 - return: wisp.bad_request() 84 - |> wisp.json_body(string_tree.from_string("Needs query params 'to'")), 100 + return: wisp.ok() 101 + |> wisp.json_body( 102 + get_all_payments_response( 103 + count_provider.new("default"), 104 + count_provider.new("fallback"), 105 + ) 106 + |> json.to_string_tree, 107 + ), 85 108 ) 86 109 87 110 let assert Ok(from) = dict.get(params, "from") ··· 134 157 135 158 wisp.ok() 136 159 |> wisp.json_body( 137 - [ 138 - #("default", count_provider.to_json(default_requests)), 139 - #("fallback", count_provider.to_json(fallback_requests)), 140 - ] 141 - |> json.object 160 + get_all_payments_response(default_requests, fallback_requests) 142 161 |> json.to_string_tree, 143 162 ) 144 163 }