OCaml client for the LinkedIn Voyager API
0
fork

Configure Feed

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

fix(lint): resolve E320 long identifiers and E205 Format-to-Fmt conversion

Shorten test identifiers exceeding 4 underscores in test_cwt.ml,
test_jsonwt.ml, and test_linkedin_url.ml. Convert Format.fprintf/sprintf
to Fmt.pf/str in ocaml-ltp/lib/ltp.ml.

+23 -16
+15 -8
lib/linkedin_url.ml
··· 17 17 in 18 18 find parts 19 19 20 + let err_not_linkedin_url s = Error (Fmt.str "not a LinkedIn URL: %s" s) 21 + 22 + let err_not_linkedin_host host = 23 + Error (Fmt.str "not a LinkedIn URL (host: %s)" host) 24 + 25 + let err_no_activity_id slug = 26 + Error (Fmt.str "could not extract activity ID from post slug: %s" slug) 27 + 28 + let err_unrecognised_path path = 29 + Error (Fmt.str "unrecognised LinkedIn URL path: %s" path) 30 + 20 31 let of_string s = 21 32 let uri = Uri.of_string s in 22 33 match Uri.host uri with 23 - | None -> Error (Fmt.str "not a LinkedIn URL: %s" s) 24 - | Some host when not (is_linkedin_host host) -> 25 - Error (Fmt.str "not a LinkedIn URL (host: %s)" host) 34 + | None -> err_not_linkedin_url s 35 + | Some host when not (is_linkedin_host host) -> err_not_linkedin_host host 26 36 | Some _ -> ( 27 37 let path = Uri.path uri in 28 38 let segments = ··· 34 44 | [ "posts"; slug ] -> ( 35 45 match extract_activity_from_slug slug with 36 46 | Some urn -> Ok (Post urn) 37 - | None -> 38 - Error 39 - (Fmt.str "could not extract activity ID from post slug: %s" slug) 40 - ) 41 - | _ -> Error (Fmt.str "unrecognised LinkedIn URL path: %s" path)) 47 + | None -> err_no_activity_id slug) 48 + | _ -> err_unrecognised_path path) 42 49 43 50 let is_url s = 44 51 let uri = Uri.of_string s in
+8 -8
test/test_linkedin_url.ml
··· 75 75 76 76 (* profile_of_string *) 77 77 78 - let test_profile_of_string_bare_id () = 78 + let test_profile_parse_bare_id () = 79 79 Alcotest.(check (result string string)) 80 80 "bare id" (Ok "johndoe") 81 81 (profile_of_string "johndoe") ··· 85 85 "url" (Ok "johndoe") 86 86 (profile_of_string "https://www.linkedin.com/in/johndoe") 87 87 88 - let test_profile_of_string_post_url () = 88 + let test_profile_parse_post_url () = 89 89 match 90 90 profile_of_string "https://www.linkedin.com/feed/update/urn:li:activity:123" 91 91 with ··· 94 94 95 95 (* post_of_string *) 96 96 97 - let test_post_of_string_bare_urn () = 97 + let test_post_parse_bare_urn () = 98 98 Alcotest.(check (result string string)) 99 99 "bare urn" (Ok "urn:li:activity:123") 100 100 (post_of_string "urn:li:activity:123") ··· 105 105 (post_of_string 106 106 "https://www.linkedin.com/feed/update/urn:li:activity:7123456789") 107 107 108 - let test_post_of_string_profile_url () = 108 + let test_post_parse_profile_url () = 109 109 match post_of_string "https://www.linkedin.com/in/johndoe" with 110 110 | Error _ -> () 111 111 | Ok v -> Alcotest.failf "expected Error, got Ok: %s" v ··· 139 139 Alcotest.test_case "invalid slug no activity" `Quick 140 140 test_invalid_slug_no_activity; 141 141 Alcotest.test_case "profile_of_string bare id" `Quick 142 - test_profile_of_string_bare_id; 142 + test_profile_parse_bare_id; 143 143 Alcotest.test_case "profile_of_string url" `Quick 144 144 test_profile_of_string_url; 145 145 Alcotest.test_case "profile_of_string post url" `Quick 146 - test_profile_of_string_post_url; 146 + test_profile_parse_post_url; 147 147 Alcotest.test_case "post_of_string bare urn" `Quick 148 - test_post_of_string_bare_urn; 148 + test_post_parse_bare_urn; 149 149 Alcotest.test_case "post_of_string url" `Quick test_post_of_string_url; 150 150 Alcotest.test_case "post_of_string profile url" `Quick 151 - test_post_of_string_profile_url; 151 + test_post_parse_profile_url; 152 152 Alcotest.test_case "pp" `Quick test_pp; 153 153 ] )