## Get Transactions

### cURL

curl --request GET \
      --url https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn/get-transaction \
      --header 'Authorization: Bearer <token>'

### Python

import requests

url = "https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn/get-transaction"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)

### JavaScript (Fetch)

const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch('https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn/get-transaction', options)
      .then(res => res.json())
      .then(res => console.log(res))
      .catch(err => console.error(err));

### PHP

<?php
    $curl = curl_init();

curl_setopt_array($curl, [
      CURLOPT_URL => "https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn/get-transaction",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => [
        "Authorization: Bearer <token>"
      ],
    ]);

$response = curl_exec($curl);
    $err = curl_error($curl);

curl_close($curl);

if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
    ?>

### Go

package main

import (
	"fmt"
	"net/http"
	"io"
    )

func main() {

url := "https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn/get-transaction"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
    }

### Java (Unirest)

HttpResponse<String> response = Unirest.get("https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn/get-transaction")
      .header("Authorization", "Bearer <token>")
      .asString();

### Ruby

require 'uri'
    require 'net/http'

url = URI("https://vanilla-dev02-loyalty.fabric.zone/api/v2/earn/get-transaction")

http = Net::HTTP.new(url.host, url.port)
    http.use_ssl = true

request = Net::HTTP::Get.new(url)
    request["Authorization"] = 'Bearer <token>'

response = http.request(request)
    puts response.read_body

### Response Codes

- 200
- 400
- 401

### Example Response (Success)
    {
      "status": 200,
      "message": "",
      "errors": {},
      "data": [
        {
          "profileId": "67460e74-02e3-11e8-b443-00163e990bdb",
          "transactionExternalReference": "LOYALTY-8675309",
          "transactionEntityReference": "Liberty_center_store",
          "transactionCode": "62660e74-02e3-11e8-b443-00163e990abc",
          "transactionTypeExternalReference": "PURCHASE",
          "transactionType": "EARN",
          "transactionActivityType": "BASE_POINTS_EARNED",
          "transactionDateTime": "2020-03-20T14:28:23.382748",
          "totalAmountPaid": 180,
          "totalTax": 20,
          "discounts": [
            {
              "id": 101,
              "value": 20,
              "type": "tier"
            }
          ],
          "discountValue": 20,
          "transactionNetAmount": 160,
          "points": 160,
          "currentPointsBalance": 360,
          "basePoints": 260,
          "bonusPoints": 100,
          "promotionalPoints": 0,
          "transactionItems": [
            {
              "grossAmount": 200,
              "totalAmountPaid": 200,
              "taxAmount": 20,
              "netAmount": 180,
              "itemPrice": 90,
              "itemQuantity": 2,
              "SKU": "1123455",
              "lineNumber": 0,
              "itemName": "demo item",
              "UOM": "unit",
              "discounts": [
                {
                  "id": 2345,
                  "value": 0,
                  "type": "promotion",
                  "description": "Black Friday discount"
                }
              ],
              "couponCodes": [
                "H4B-1000"
              ]
            }
          ],
          "activityTimestamp": "2020-02-08 09:30:26",
          "transactionNumber": "LOYALTY-8675309",
          "reasonCode": "9393",
          "reasonDescription": "earning item",
          "deviceId": "D10626",
          "issueAuditUser": "Joe",
          "cancelAuditUser": "John",
          "rewards": [
            {
              "reward_id": 111,
              "core_rule_id": 2,
              "reward_portion": 10
            }
          ]
        }
      ]
    }

### Example Response (Error)
    {
      "message": "Error message string",
      "errors": {
        "ExceptionString": [
          "Invalid Field"
        ]
      },
      "data": null,
      "status": 400
    }

{
      "detail": "Authentication Failed"
    }

### Authorizations

- **Authorization**: Required header in format `Bearer <token>`

### Query Parameters

- **profileId**: The Profile ID of the member, generated as part of the Enroll Member endpoint.
- **startTimestampUTC**: Start date of the selected date range (UTC format)
- **endTimestampUTC**: End date of the selected date range (UTC format)
- **transactionExternalReference**: External reference (name or ID) of the transaction.
- **transactionType**: Refers to the different types of account transaction activities, such as `EARN`, `BURN`, etc.
- **transactionCode**: Transaction Code in UUID format.
- **offset**: Starting record number for the response.
- **limit**: Final record number in the response.
