Skip to content

Getting Started

Sandy Wright edited this page May 28, 2020 · 18 revisions

Let's walk through setting up your environment to make your first API call to the Prime API.

  1. Install dependencies
  2. Check out the MilMove project
  3. Run the Docker container
  4. Use the CLI Prime API Client

Install Dependencies

Required Libraries:

Homebrew

Homebrew is the package manager we use to install the rest of the dependencies.

  • Use the following command to install Homebrew:
    • /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    • Note: You'll be prompted to install Xcode Command Line Tools if you don't have them already.

Go

The backend server and client tool are written in Golang. Please read through the steps even if you already use Go, since there are required changes to your PATH.

  • brew install go
  • Notes:
    • Current Go version: go1.14 (released 2020/02/25)
    • We normally use the latest version of Go unless there's a known conflict (which will be announced by the team) or if we're in the time period just after a new version has been released.
    • If you have previously modified your PATH to point to a specific version of go, make sure to remove that. This would be either in your .bash_profile or .bashrc, and might look something like PATH=$PATH:/usr/local/opt/go@1.12/bin.
  • Add the following to your .bash_profile:
    • export GOPATH=${GOPATH:-$(go env GOPATH)}
    • export PATH=$(go env GOPATH)/bin:$PATH
  • Apply the changes to your shell:
    • source ~/.bash_profile

Docker

We use Docker to automate much of the process of setting up your environment, creating databases, and running the server you need to access the Prime API.

Docker Compose

direnv

To ensure that the local environment variables are set up correctly, we use direnv to load them when you cd into the directory.

  • brew install direnv
  • For direnv to work properly, it needs to be hooked into the shell.
    • Once the hook is configured, restart your shell for direnv to be activated.

BASH

Add the following line at the end of your ~/.bash_profile:

eval "$(direnv hook bash)"

Make sure it appears even after rvm, git-prompt and other shell extensions that manipulate the prompt.

ZSH

Add the following line at the end of the ~/.zshrc file:

eval "$(direnv hook zsh)"

jq

jq is a command-line JSON processor used with the CLI Prime API Client tool.

  • brew install jq

yarn

Yarn is a dependency manager used by the Dockerfile.

  • brew install yarn

Checkout Project

You can checkout this repository by running git clone git@github.com:transcom/mymove.git. Please check out the code in a directory like ~/Projects/mymove and NOT in your $GOPATH. As an example:

mkdir -p ~/Projects
git clone git@github.com:transcom/mymove.git
cd mymove

Local Env Variables

  • Copy .envrc.local.template to .envrc.local if you do not already have .envrc.local.

    • cp .envrc.local.template .envrc.local
  • This template contains the environment variables needed to start using the application, except one. You need to generate your local secret key using these instructions.

Run Prime Docker

Make sure you've installed the dependencies before proceeding. From the /mymove directory, run:

make run_prime_docker

Wait for the script to finish running. When finished, you should see [#TODO--get expected view/text].

Run Prime API Client

To verify your setup is working correctly, you can quickly test the API using the prime-api-client CLI tool. For this example, we'll GET /move-task-orders, which returns an array of all move task orders.

Run: go run ./cmd/prime-api-client --insecure fetch-mto-updates

You should see a response similar to:

   [
        {
          "createdAt": "2020-03-23",
          "id": "c66e2e16-4b3c-467b-a3a8-c80e46135dd2",
          "isAvailableToPrime": true,
          "isCanceled": false,
          "moveOrder": {
            "confirmationNumber": "GBQP4Q",
            "customer": {
              "branch": "COAST_GUARD",
              "currentAddress": {
                "city": "",
                "id": "00000000-0000-0000-0000-000000000000",
                "postalCode": "",
                "state": "",
                "streetAddress1": ""
              },
              ...
        },
        ...
    ]

Congrats! You've made your first call to the Prime API.

Shutting down Docker

When you're finished testing, remember to shut down the server:

make docker_compose_down

Next Steps