4646 :group 'tools )
4747
4848(defcustom impostman-auth-basic-as-elisp-code t
49- " Convert Basic authentication header to elisp code so that the username
50- and password can be easily edited.
49+ " Convert Basic authentication header to elisp code for easy edit.
5150
5251Example with verb:
53- Authorization: Basic {{(base64-encode-string (encode-coding-string \" username:password\" 'utf-8) t)}}
52+ Authorization: Basic {{(base64-encode-string
53+ (encode-coding-string \" username:password\" 'utf-8) t)}}
5454
5555Example with restclient:
56- :auth := (format \" Basic %s\" (base64-encode-string (encode-coding-string \" username:password\" 'utf-8) t))
56+ :auth := (format \" Basic %s\" (base64-encode-string
57+ (encode-coding-string \" username:password\" 'utf-8) t))
5758Authorization: :auth
5859
5960If nil, the username and password are directly encoded in base64:
6061Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ="
6162 :type 'boolean )
6263
6364(defcustom impostman-use-variables t
64- " Keep Postman variables in the output and define variables according to the
65- output.
65+ " Keep Postman variables in the output and define variables.
6666
6767If nil, no variables are used, they are directly replaced by their values
6868during the import of collection."
6969 :type 'boolean )
7070
7171(defconst impostman-version " 0.2.0-snapshot"
72- " Impostman package version" )
72+ " Impostman package version. " )
7373
7474(defconst impostman-output-verb-alist
7575 '((init . ignore)
@@ -79,7 +79,7 @@ during the import of collection."
7979 (request . impostman-output-verb-request)
8080 (footer . impostman-output-verb-footer)
8181 (end . impostman-output-verb-end))
82- " Emacs verb output" )
82+ " Emacs verb output. " )
8383
8484(defconst impostman-output-restclient-alist
8585 '((init . ignore)
@@ -89,12 +89,12 @@ during the import of collection."
8989 (request . impostman-output-restclient-request)
9090 (footer . impostman-output-restclient-footer)
9191 (end . impostman-output-restclient-end))
92- " Emacs restclient output" )
92+ " Emacs restclient output. " )
9393
9494(defcustom impostman-outputs-alist
9595 '((" verb" . impostman-output-verb-alist)
9696 (" restclient" . impostman-output-restclient-alist))
97- " Impostman outputs"
97+ " Impostman outputs. "
9898 :type '(alist :key-type string :value-type function))
9999
100100; ; functions common to all outputs
@@ -114,8 +114,8 @@ PREFIX is the prefix to add in front of each line (default is \"# \")."
114114 " \n " ))))
115115
116116(defun impostman-get-auth-basic-plain (authorization )
117- " Get the plain-text \" username:password\" with the value of the
118- Authorization header, if it is Basic authentication.
117+ " Get the plain-text \" username:password\" given an AUTHORIZATION header.
118+
119119For example with the value \" Basic dXNlcm5hbWU6cGFzc3dvcmQ=\" ,
120120the function returns \" username:password\" .
121121Return nil if the authentication is not Basic or if the base64 is invalid."
@@ -129,7 +129,7 @@ Return nil if the authentication is not Basic or if the base64 is invalid."
129129 " Replace variables in a string, using verb syntax.
130130
131131STRING any string that can contain variables with format \" {{variable}}\" .
132- VARIABLES is a alist with Postman variables."
132+ VARIABLES is an alist with Postman variables."
133133 (if impostman-use-variables
134134 (replace-regexp-in-string
135135 " {{\\ ([^}]+\\ )}}" " {{(verb-var \\ 1)}}" (or string " " ))
@@ -146,7 +146,7 @@ VARIABLES is a alist with Postman variables."
146146
147147NAME is the collection name.
148148DESCRIPTION is the collection description.
149- VARIABLES is a alist with Postman variables."
149+ VARIABLES is an alist with Postman variables."
150150 (ignore variables)
151151 (concat
152152 " * " name " :verb:" " \n "
@@ -158,7 +158,7 @@ VARIABLES is a alist with Postman variables."
158158LEVEL is the level.
159159NAME is the item name.
160160DESCRIPTION is the item description.
161- VARIABLES is a alist with Postman variables."
161+ VARIABLES is an alist with Postman variables."
162162 (ignore variables)
163163 (concat
164164 (if (<= level 2 ) " \n " " " )
@@ -173,7 +173,7 @@ METHOD is the HTTP method.
173173URL is the URL.
174174HEADERS is an alist with HTTP headers.
175175BODY is the request body.
176- VARIABLES is a alist with Postman variables."
176+ VARIABLES is an alist with Postman variables."
177177 (ignore variables)
178178 (let (list-headers)
179179 (dolist (header (nreverse headers))
@@ -201,7 +201,7 @@ VARIABLES is a alist with Postman variables."
201201 " Format the verb footer.
202202
203203NAME is the collection name.
204- VARIABLES is a alist with Postman variables."
204+ VARIABLES is an alist with Postman variables."
205205 (let (list-vars)
206206 (when impostman-use-variables
207207 (dolist (var (nreverse variables))
@@ -221,7 +221,7 @@ VARIABLES is a alist with Postman variables."
221221(defun impostman-output-verb-end (variables )
222222 " Function evaluated at the end.
223223
224- VARIABLES is a alist with Postman variables."
224+ VARIABLES is an alist with Postman variables."
225225 (when (fboundp 'org-mode )
226226 (org-mode ))
227227 (when (fboundp 'verb-mode )
@@ -237,7 +237,7 @@ VARIABLES is a alist with Postman variables."
237237 " Replace variables in a string, using restclient syntax.
238238
239239STRING any string that can contain variables with format \" {{variable}}\" .
240- VARIABLES is a alist with Postman environment variables."
240+ VARIABLES is an alist with Postman variables."
241241 (if impostman-use-variables
242242 (replace-regexp-in-string
243243 " {{\\ ([^}]+\\ )}}" " :\\ 1" (or string " " ))
@@ -254,7 +254,7 @@ VARIABLES is a alist with Postman environment variables."
254254
255255NAME is the collection name.
256256DESCRIPTION is the collection description.
257- VARIABLES is a alist with Postman environment variables."
257+ VARIABLES is an alist with Postman variables."
258258 (let (list-vars)
259259 (when impostman-use-variables
260260 (dolist (var (nreverse variables))
@@ -273,7 +273,8 @@ VARIABLES is a alist with Postman environment variables."
273273
274274LEVEL is the level.
275275NAME is the item name.
276- DESCRIPTION is the item description."
276+ DESCRIPTION is the item description.
277+ VARIABLES is an alist with Postman variables."
277278 (ignore variables)
278279 (concat
279280 (if (<= level 2 ) " \n " " " )
@@ -287,7 +288,8 @@ DESCRIPTION is the request description.
287288METHOD is the HTTP method.
288289URL is the URL.
289290HEADERS is an alist with HTTP headers.
290- BODY is the request body."
291+ BODY is the request body.
292+ VARIABLES is an alist with Postman variables."
291293 (ignore variables)
292294 (let (list-variables list-headers)
293295 (dolist (header (nreverse headers))
@@ -318,14 +320,16 @@ BODY is the request body."
318320 " Format the restclient footer.
319321
320322NAME is the collection name.
321- VARIABLES is a alist with Postman environment variables."
323+ VARIABLES is an alist with Postman variables."
322324 (ignore variables)
323325 (concat
324326 " \n "
325327 " # End of " name " \n " ))
326328
327329(defun impostman-output-restclient-end (variables )
328- " Function evaluated at the end."
330+ " Function evaluated at the end.
331+
332+ VARIABLES is an alist with Postman variables."
329333 (ignore variables)
330334 (when (fboundp 'restclient-mode )
331335 (restclient-mode)))
@@ -388,8 +392,9 @@ HEADER is a vector with hash tables."
388392 headers))
389393
390394(defun impostman--build-auth-query-string (auth )
391- " Return query string parameter to add for authentication as an alist, for
392- example: (\" key\" . \" value\" ), or nil if there's no query string to add.
395+ " Return query string parameter to add for authentication as an alist.
396+
397+ For example: (\" key\" . \" value\" ), or nil if there's no query string to add.
393398
394399AUTH is a hash table."
395400 (let (query-string-items)
@@ -417,7 +422,7 @@ AUTH is a hash table."
417422 " Return the URL with updated query string parameters.
418423
419424URL is a string.
420- QUERY-STRING is nil or an alist with query strings to add."
425+ QUERY-STRING-ITEMS is nil or an alist with query strings to add."
421426 (dolist (query-string query-string-items)
422427 (setq url (concat
423428 url
@@ -428,8 +433,7 @@ QUERY-STRING is nil or an alist with query strings to add."
428433 url)
429434
430435(defun impostman--build-variables (values )
431- " Return alist with variables using values from Postman collection and
432- environment.
436+ " Return alist with variables using Postman collection/environment.
433437
434438VALUES is the \" variable\" read from collection (vector) or \" values\" read
435439from environment (vector) (or concatenation of both)."
@@ -449,7 +453,7 @@ from environment (vector) (or concatenation of both)."
449453
450454ITEMS is the \" item\" read from collection (vector).
451455LEVEL is the level.
452- VARIABLES is a alist with Postman variables.
456+ VARIABLES is an alist with Postman variables.
453457OUTPUT-ALIST is an alist with the output callbacks."
454458 (dotimes (i (length items))
455459 (let* ((item (elt items i))
@@ -491,7 +495,7 @@ OUTPUT-ALIST is an alist with the output callbacks."
491495 description method2 url2 headers body2 variables)))))))))
492496
493497(defun impostman--parse-json (collection environment output-alist )
494- : " Parse a Postman collection using an optional Postman environment.
498+ " Parse a Postman collection using an optional Postman environment.
495499
496500COLLECTION is a hash table with the Postman collection (parsed JSON).
497501ENVIRONMENT is a hash table with the Postman environment (parsed JSON).
@@ -519,8 +523,7 @@ OUTPUT-ALIST is an alist with the output callbacks."
519523
520524;;;### autoload
521525(defun impostman-parse-file (collection environment output-alist )
522- " Parse a file with a Postman collection, using an optional file with
523- a Postman environment (for variables).
526+ " Parse a file with a Postman collection.
524527
525528COLLECTION is a Postman collection filename.
526529ENVIRONMENT is a Postman environment filename (optional).
@@ -537,8 +540,7 @@ OUTPUT-ALIST is an alist with the output callbacks."
537540
538541;;;### autoload
539542(defun impostman-parse-string (collection environment output-alist )
540- " Parse a string with a Postman collection, using an optional string with
541- a Postman environment (for variables).
543+ " Parse a string with a Postman collection.
542544
543545COLLECTION is a string with a Postman collection.
544546ENVIRONMENT is a string with a Postman environment (optional).
@@ -563,8 +565,9 @@ OUTPUT-ALIST is an alist with the output callbacks."
563565 (read-file-name " Postman environment file (JSON, optional): " )))
564566
565567(defun impostman-read-output ()
566- " Read Postman output type, which must be a key from alist
567- `impostman-outputs-alist' .
568+ " Read Postman output type.
569+
570+ It which must be a key from alist `impostman-outputs-alist' .
568571
569572If the alist size is 1, the value is immediately returned without asking
570573anything."
@@ -577,17 +580,17 @@ anything."
577580 prompt impostman-outputs-alist nil t nil nil default ))))
578581
579582(defun impostman--get-output-alist (name )
580- " Get output alist with a given NAME. A key with this name must exist in
581- `impostman-outputs-alist' ."
583+ " Get output alist with a given NAME.
584+
585+ A key with this name must exist in `impostman-outputs-alist' ."
582586 (let ((output-alist (assoc name impostman-outputs-alist)))
583587 (if output-alist
584588 (symbol-value (cdr output-alist))
585589 (error (format " Output \" %s \" is not supported " name)))))
586590
587591;;;### autoload
588592(defun impostman-import-file (&optional collection environment output-name )
589- " Import a file with a Postman collection, using optional file with
590- a Postman environment (for variables).
593+ " Import a file with a Postman collection.
591594
592595COLLECTION is a Postman collection filename.
593596ENVIRONMENT is a Postman environment filename (optional).
@@ -601,8 +604,7 @@ OUTPUT-NAME is a string with the desired output (eg: \"verb\")."
601604
602605;;;### autoload
603606(defun impostman-import-string (collection environment &optional output-name )
604- " Import a string with a Postman collection, using optional file with
605- a Postman environment (for variables).
607+ " Import a string with a Postman collection.
606608
607609COLLECTION is a string with a Postman collection.
608610ENVIRONMENT is a string with a Postman environment (optional).
0 commit comments