{
    "info": {
        "name": "Rainbow Invoicing portal (1.170.0)",
        "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
        "description": "#Rainbow Invoicing Portal\n\nIn order to run the requests from the collection \"**Rainbow Invoicing portal**\", the following variables has to be set in Postman:\n   - `PortalServersUrl`: URL of the API portal, shall be set in environment variable (ex: openrainbow.net, demo.openrainbow.com, ...).\n     If not set, default URL used is https://openrainbow.com\n     \nVariables for authentication (only needed for Authentication portal collection)\n   - `userLogin`: login of the user, can be set in global variable if user login\n     is the same in all environments, or in environment variable (ex: user@company.com)\n   - `userPwd`: password of the user, can be set in global variable if user password\n     is the same in all environments, or in environment variable (ex: Password_123)\n   - `appId`: appId of the application, shall be set in environment variable as\n     appId is probably different between environments (ex: 304596006e3c11e88205e19d39f12481)\n   - `appSecret`: appSecret of the application, shall be set in environment variable as\n     appSecret is different between environments (ex: jAalnHOEiHEVIcuxVrYwXznrv5MLPLadHj7Fmy7x0DHm21Y1MS1uB5kEWOdAtuVn)\n "
    },
    "auth": {
        "type": "bearer",
        "bearer": [
            {
                "key": "token",
                "value": "{{token_user}}",
                "type": "string"
            }
        ]
    },
    "event": [
        {
            "listen": "prerequest",
            "script": {
                "type": "text/javascript",
                "exec": [
                    "// If InvoicingPortalServer environment variable is not set, use PortalServersUrl variable from environment or global variables (if PortalServersUrl is not set fallback on https://openrainbow.com)",
                    "let rainbowServersUrl = pm.variables.get(\"PortalServersUrl\");",
                    "if (!pm.variables.get(\"InvoicingPortalServer\")) {",
                    "    if (rainbowServersUrl) {",
                    "        // Prefix PortalServersUrl by https:// if not set in variable",
                    "        if (!rainbowServersUrl.startsWith(\"https://\") && !rainbowServersUrl.startsWith(\"http://\")) {",
                    "            rainbowServersUrl = `https://${rainbowServersUrl}`;",
                    "        }",
                    "        console.log(`InvoicingPortalServer environment variable is not set, set it to PortalServersUrl's value (${rainbowServersUrl})`);",
                    "        pm.environment.set(\"InvoicingPortalServer\", rainbowServersUrl);",
                    "    } else {",
                    "        // Use production environment if none of InvoicingPortalServer or PortalServersUrl is set",
                    "        pm.environment.set(\"InvoicingPortalServer\", \"https://openrainbow.com\");",
                    "    }",
                    "}"
                ]
            }
        },
        {
            "listen": "test",
            "script": {
                "type": "text/javascript",
                "exec": [
                    "pm.test(\"Is success response?\", function () {",
                    "    switch (pm.request.method) {",
                    "        case \"GET\":",
                    "        case \"PUT\":",
                    "        case \"DELETE\":",
                    "            pm.response.to.have.status(200);",
                    "            break;",
                    "        case \"POST\":",
                    "            pm.expect(pm.response.code).to.be.oneOf([200,201]);",
                    "            break;",
                    "        default:",
                    "            console.warn(`Response status code is not checked for method ${pm.request.method}`);",
                    "    }",
                    "});"
                ]
            }
        }
    ],
    "item": [
        {
            "name": "invoices",
            "description": "invoices",
            "item": [
                {
                    "name": "Download an available invoice",
                    "request": {
                        "method": "GET",
                        "url": {
                            "raw": "{{InvoicingPortalServer}}/api/rainbow/invoicing/v1.0/invoices/:invoicePath",
                            "host": [
                                "{{InvoicingPortalServer}}"
                            ],
                            "path": [
                                "api",
                                "rainbow",
                                "invoicing",
                                "v1.0",
                                "invoices",
                                ":invoicePath"
                            ],
                            "variable": [
                                {
                                    "key": "invoicePath",
                                    "description": "path of the file to download (e.g. 000000001111110001000010/2017-10/services/CDR_SERV_2017-10-10_DR_dr_bp_test.csv)"
                                }
                            ]
                        },
                        "body": {},
                        "description": "Required role(s): `business_admin`, `bp_finance`, `organization_admin`, `company_admin`\n\n<p>This API allows <code>superadmin</code>, <code>bp_finance</code> and <code>admin</code> to download a given invoice. <br/> To download an invoice, admin should use filepath provided by GET /api/rainbow/invoicing/v1.0/invoices API. <br/> Example of request to download an invoice : GET /api/rainbow/invoicing/v1.0/invoices/000000001111110001000010/2017-10/services/CDR_SERV_2017-10-10_DR_dr_bp_test.csv</p>"
                    },
                    "response": [
                        {
                            "name": "Success-Response:",
                            "originalRequest": {
                                "method": "GET",
                                "url": {
                                    "raw": "{{InvoicingPortalServer}}/api/rainbow/invoicing/v1.0/invoices/:invoicePath",
                                    "host": [
                                        "{{InvoicingPortalServer}}"
                                    ],
                                    "path": [
                                        "api",
                                        "rainbow",
                                        "invoicing",
                                        "v1.0",
                                        "invoices",
                                        ":invoicePath"
                                    ],
                                    "variable": [
                                        {
                                            "key": "invoicePath",
                                            "description": "path of the file to download (e.g. 000000001111110001000010/2017-10/services/CDR_SERV_2017-10-10_DR_dr_bp_test.csv)"
                                        }
                                    ]
                                },
                                "body": {},
                                "description": "Required role(s): `business_admin`, `bp_finance`, `organization_admin`, `company_admin`\n\n<p>This API allows <code>superadmin</code>, <code>bp_finance</code> and <code>admin</code> to download a given invoice. <br/> To download an invoice, admin should use filepath provided by GET /api/rainbow/invoicing/v1.0/invoices API. <br/> Example of request to download an invoice : GET /api/rainbow/invoicing/v1.0/invoices/000000001111110001000010/2017-10/services/CDR_SERV_2017-10-10_DR_dr_bp_test.csv</p>"
                            },
                            "status": "OK",
                            "code": 200,
                            "_postman_previewlanguage": "csv",
                            "header": [],
                            "body": "invoiceLine;invoiceCreationDate;invoicePeriod;invoiceReference;exportReference;bp1TCRDId;bp1TApplicantNumber;bp1TApplicantName;bp2TCRDId;bp2TApplicantNumber1;bp2TApplicantNumber2;bp2TApplicantName;endCustomerCompanyId;endCustomerCompanyId1ByBp;endCustomerCompanyId2ByBp;endCustomerCompanyName;aleServiceReference;rainbowServiceId;rainbowServiceDescription;subscriptionReference;empty1;empty2;empty3;empty4;unit;volume;wplPricePerUnit;wplPriceTotal;categoryCode;bp1TDiscountValue;bp1TNetUnitValue;bp1TNetTotalValue;bp2TDiscountValue;bp2TNetUnitValue;bp2TNetTotalValue;endCustomerDiscountValue;endCustomerNetUnitValue;endCustomerNetTotalValue;currency\n1;2017-10-10;2017-10;CDR_SERV_2017-10-10_DR_dr_bp_test.csv;dr_bp_test_2017-10;741963;HAGSH87176;DR_BP_TEST;;;;;000000001111110001000010;;;DR_BP_TEST;3EY95001AA;RB-Essential;Rainbow Essential Subscription;000000001111110002000010;;;;;Users;2;1.000;2.0000;RB-SP1;0.3;0.7;1.4000;;;;;;;USD\n2;2017-10-10;2017-10;CDR_SERV_2017-10-10_DR_dr_bp_test.csv;dr_bp_test_2017-10;741963;HAGSH87176;DR_BP_TEST;;;;;000000001111110001000010;;;DR_BP_TEST;3EY95002AA;RB-Business;Rainbow Business Subscription;RB-201706015813;;;;;Users;12;2.000;24.0000;RB-SP1;0.3;1.4;16.8000;;;;;;;USD"
                        }
                    ]
                },
                {
                    "name": "List all available invoices",
                    "request": {
                        "method": "GET",
                        "url": {
                            "raw": "{{InvoicingPortalServer}}/api/rainbow/invoicing/v1.0/invoices",
                            "host": [
                                "{{InvoicingPortalServer}}"
                            ],
                            "path": [
                                "api",
                                "rainbow",
                                "invoicing",
                                "v1.0",
                                "invoices"
                            ],
                            "query": [
                                {
                                    "key": "companyId",
                                    "description": "companyId for which invoices should be listed",
                                    "disabled": true
                                },
                                {
                                    "key": "billingPeriod",
                                    "description": "Period for which invoice should be listed (e.g. 2017-08)",
                                    "disabled": true
                                },
                                {
                                    "key": "invoiceType",
                                    "description": "Type of invoice that should be listed (services or conference)",
                                    "disabled": true
                                },
                                {
                                    "key": "fileType",
                                    "description": "Type of file that should be listed (INV or CDR)",
                                    "disabled": true
                                },
                                {
                                    "key": "invoiceCreationDate",
                                    "description": "Allow to filter invoices on <codinvoiceCreationDate</cod. This is an exact match: API will return only invoices matching the given date. Expected format is : YYYY-MM-DD",
                                    "disabled": true
                                },
                                {
                                    "key": "fromInvoiceCreationDate",
                                    "description": "Allow to filter invoices on <codinvoiceCreationDate</cod. API will return only invoices with invoiceCreationDate greater than the given date. </b </bExpected format is : YYYY-MM-DD </b </bNote: if <codinvoiceCreationDate</cod filter is provided, <codfromInvoiceCreationDate</cod will be ignored.",
                                    "disabled": true
                                },
                                {
                                    "key": "toInvoiceCreationDate",
                                    "description": "Allow to filter invoices on <codinvoiceCreationDate</cod. API will return only invoices with invoiceCreationDate lower than the given date. </b </bExpected format is : YYYY-MM-DD </b </bNote: if <codinvoiceCreationDate</cod filter is provided, <codtoInvoiceCreationDate</cod will be ignored.",
                                    "disabled": true
                                }
                            ]
                        },
                        "body": {},
                        "description": "Required role(s): `business_admin`, `bp_finance`, `organization_admin`, `company_admin`\n\n<p>This API allows <code>superadmin</code>, <code>bp_finance</code> and <code>admin</code> to list all available invoices. <br/></p>"
                    },
                    "response": [
                        {
                            "name": "Success-Response:",
                            "originalRequest": {
                                "method": "GET",
                                "url": {
                                    "raw": "{{InvoicingPortalServer}}/api/rainbow/invoicing/v1.0/invoices",
                                    "host": [
                                        "{{InvoicingPortalServer}}"
                                    ],
                                    "path": [
                                        "api",
                                        "rainbow",
                                        "invoicing",
                                        "v1.0",
                                        "invoices"
                                    ],
                                    "query": [
                                        {
                                            "key": "companyId",
                                            "description": "companyId for which invoices should be listed",
                                            "disabled": true
                                        },
                                        {
                                            "key": "billingPeriod",
                                            "description": "Period for which invoice should be listed (e.g. 2017-08)",
                                            "disabled": true
                                        },
                                        {
                                            "key": "invoiceType",
                                            "description": "Type of invoice that should be listed (services or conference)",
                                            "disabled": true
                                        },
                                        {
                                            "key": "fileType",
                                            "description": "Type of file that should be listed (INV or CDR)",
                                            "disabled": true
                                        },
                                        {
                                            "key": "invoiceCreationDate",
                                            "description": "Allow to filter invoices on <codinvoiceCreationDate</cod. This is an exact match: API will return only invoices matching the given date. Expected format is : YYYY-MM-DD",
                                            "disabled": true
                                        },
                                        {
                                            "key": "fromInvoiceCreationDate",
                                            "description": "Allow to filter invoices on <codinvoiceCreationDate</cod. API will return only invoices with invoiceCreationDate greater than the given date. </b </bExpected format is : YYYY-MM-DD </b </bNote: if <codinvoiceCreationDate</cod filter is provided, <codfromInvoiceCreationDate</cod will be ignored.",
                                            "disabled": true
                                        },
                                        {
                                            "key": "toInvoiceCreationDate",
                                            "description": "Allow to filter invoices on <codinvoiceCreationDate</cod. API will return only invoices with invoiceCreationDate lower than the given date. </b </bExpected format is : YYYY-MM-DD </b </bNote: if <codinvoiceCreationDate</cod filter is provided, <codtoInvoiceCreationDate</cod will be ignored.",
                                            "disabled": true
                                        }
                                    ]
                                },
                                "body": {},
                                "description": "Required role(s): `business_admin`, `bp_finance`, `organization_admin`, `company_admin`\n\n<p>This API allows <code>superadmin</code>, <code>bp_finance</code> and <code>admin</code> to list all available invoices. <br/></p>"
                            },
                            "status": "OK",
                            "code": 200,
                            "_postman_previewlanguage": "json",
                            "header": [],
                            "body": "[\n {\n   \"companyId\": \"000000001111110001000010\",\n   \"billingPeriod\": \"2017-10\",\n   \"invoiceType\": \"services\",\n   \"filename\": \"CDR_SERV_2017-10-10_DR_dr_bp_test.csv\",\n   \"filepath\": \"000000001111110001000010/2017-10/services/CDR_SERV_2017-10-10_DR_dr_bp_test.csv\",\n   \"invoiceCreationDate\": \"2017-10-10\"\n }\n]"
                        }
                    ]
                }
            ]
        }
    ]
}