Skip to content

Working with Visual Studio Code Plugin

This guide explains how to use the Swytchcode VSC plugin to generate code for API methods and workflows. The plugin is structured into four main sections, each allowing you to perform specific actions. Let’s explore them in detail.

"VSC plugin walkthrough"

  1. Criteria selector: The criteria selector allows you to switch between workflows and API methods. Changing this option will update the menu options in the next section.
  2. Filters: Filters help you quickly search for methods or workflows within a library. Swytchcode supports code generation for various library versions in 14 different programming languages.
    • Organization: Select the organization that owns the library.
    • API: View the list of library services provided by the selected organization.
    • Version: Choose the API library version for code generation.
    • Language: Select the programming language for the code to be generated.
    • Method: Choose the method for which code will be generated.
  3. Code editor: The code editor displays the generated code fetched from Swytchcode.
  4. Command History: This section keeps a record of your past code generation activities.

Now, let’s walk through an example of fetching code for both API methods and workflows using Stripe.


Code for Methods

  1. From the Criteria selector choose Select Method to fetch code for an API method

"select method"

  1. Now in the Filters section, from the “Search organization” menu option, look for “Stripe”

"select organization"

  1. Stripe organization has only one library which is again called “Stripe”.

"select library"

  1. Select the version of your choice. As of writing this document, we offer support for only the latest version of Stripe (v3)

"select version"

  1. Let’s generate code in Typescript

"select language"

  1. Click “Search Method:“
    If the methods and code is available in choice of your programming language you will see the list of API methods. In case you don’t see any methods in the list, you will have to go to the web application and generate code in choice of your programming language (Checkout this guide).

"select method"

  1. Click “Copy Method” button after your filter criteria is selected

"copy method"

  1. Paste the copied method in a new file in the Code editor, the method name will appear in between the <Swytch>..</Swytch> in the comment format. Select the whole method using your keyboard using Cmd+A on Mac or Ctrl+A on other OS. Press the Enter or Return key from the keyboard

"select the prompt and hit enter"

  1. Success : Code fetched successfully for the selected method. The generated code is 99% accurate and you can directly use it to integrate the selected method.

"Generated code"


Code for Workflows

Fetching workflow code in the plugin is very similar to the code generation. Only a few steps change

  1. From the criteria selector, select Select Workflow

"select workflow"

  1. Steps for selecting an organization, library and version are similar to the steps in the above section. Only existing published workflows are displayed in the list. You can create your own workflow and publish from our web application (Please read this guide). Proceed to select an existing published workflow from the dropdown.

"select from workflow list"

  1. Click “Copy Workflow” button to copy the workflow name

"copy workflow"

  1. Paste the workflow name and select the whole name before hitting the enter key from your keyboard to fetch the code

"generate workflow code"