def lines(self,
           params: InvoiceLinesInputParams = None) -> InvoiceLinesType:
     params = "?" + params.as_url_param() if params is not None else ""
     return DataclassWrapper.wrap(
         InvoiceLinesType,
         self.execute("get", "/".join(["invoices", "lines"]) + params),
     )
 def save(self) -> CostCenterDetail:
     return DataclassWrapper.wrap(
         CostCenterDetail,
         self.travelperk.patch("/".join(["cost_centers",
                                         str(self.id)]),
                               self.params.to_dict()),
     )
Beispiel #3
0
 def get(self, id: int) -> User:
     return DataclassWrapper.wrap(
         User,
         humps.decamelize(
             self.execute("get", "/".join(["scim", "Users",
                                           str(id)]))),
     )
Beispiel #4
0
 def save(self) -> User:
     return DataclassWrapper.wrap(
         User,
         humps.decamelize(
             self.execute("post", "/".join(["scim", "Users"]),
                          self.params.to_dict())),
     )
Beispiel #5
0
 def replace(self, id: int, params: ReplaceUserInputParams) -> User:
     return DataclassWrapper.wrap(
         User,
         humps.decamelize(
             self.execute("put", "/".join(["scim", "Users", id]),
                          params.to_dict())),
     )
Beispiel #6
0
 def get(self) -> InvoicesType:
     return DataclassWrapper.wrap(
         InvoicesType,
         self.execute(
             "get",
             "/".join(["invoices"]) + "?" + self.params.as_url_param()),
     )
Beispiel #7
0
 def get(self) -> Bookings:
     return DataclassWrapper.wrap(
         Bookings,
         self.execute(
             "get",
             "/".join(["bookings"]) + "?" + self.params.as_url_param(),
         ),
     )
 def get(self) -> Users:
     return DataclassWrapper.wrap(
         Users,
         self.execute(
             "get",
             "/".join(["users"]) + "?" + self.params.as_url_param(),
         ),
     )
 def save(self) -> BulkUpdateResponse:
     return DataclassWrapper.wrap(
         BulkUpdateResponse,
         self.travelperk.patch(
             "/".join(["cost_centers", "bulk_update"]),
             self.params.to_dict(),
         ),
     )
Beispiel #10
0
    def hotel_emissions(self, country_code: str, num_nights: int) -> Emissions:
        params = HotelEmissionsParams(country_code, num_nights)

        return DataclassWrapper.wrap(
            HotelEmissions,
            self.execute(
                "get",
                "/".join(["emissions", "hotel"]) + "?" + params.as_url_param(),
            ),
        )
 def airline_safety_measures(self, iata: str) -> AirlineMeasure:
     return DataclassWrapper.wrap(
         AirlineMeasure,
         self.execute(
             "get",
             "/".join(["travelsafe", "airline_safety_measures"])
             + "?iata_code="
             + iata,
         ),
     )
 def get(self) -> Users:
     return DataclassWrapper.wrap(
         Users,
         humps.decamelize(
             self.execute(
                 "get",
                 "/".join(["scim", "Users"]) + "?" +
                 self.params.as_url_param(),
             )),
     )
Beispiel #13
0
 def create(self, username: str, active: bool, given_name: str,
            family_name: str) -> User:
     name = NameInputParams(given_name, family_name)
     params = CreateUserInputParams(username, active, name)
     return DataclassWrapper.wrap(
         User,
         humps.decamelize(
             self.execute("post", "/".join(["scim", "Users"]),
                          params.to_dict())),
     )
    def local_summary(self, location: str, location_type: str) -> Summary:
        params = LocalSummaryParams(location, location_type)

        return DataclassWrapper.wrap(
            Summary,
            self.execute(
                "get",
                "/".join(["travelsafe", "guidelines"]) + "?" + params.as_url_param(),
            ),
        )
Beispiel #15
0
    def car_emissions(
        self, acriss_code: str, num_days: int, distance_per_day: int = None
    ) -> Emissions:
        params = CarEmissionsParams(acriss_code, num_days, distance_per_day)

        return DataclassWrapper.wrap(
            Emissions,
            self.execute(
                "get",
                "/".join(["emissions", "car"]) + "?" + params.as_url_param(),
            ),
        )
Beispiel #16
0
    def train_emissions(
        self, origin_id: str, destination_id: str, vendor: str = None
    ) -> Emissions:
        params = TrainEmissionsParams(origin_id, destination_id, vendor)

        return DataclassWrapper.wrap(
            Emissions,
            self.execute(
                "get",
                "/".join(["emissions", "train"]) + "?" + params.as_url_param(),
            ),
        )
Beispiel #17
0
    def flight_emissions(
        self, origin: str, destination: str, cabin_class: str, airline_code: str
    ) -> Emissions:
        params = FlightEmissionsParams(origin, destination, cabin_class, airline_code)

        return DataclassWrapper.wrap(
            Emissions,
            self.execute(
                "get",
                "/".join(["emissions", "flight"]) + "?" + params.as_url_param(),
            ),
        )
    def travel_restrictions(
        self,
        origin: str,
        destination: str,
        origin_type: str,
        destination_type: str,
        date: datetime,
    ) -> Restriction:
        params = TravelRestrictionParams(
            origin, destination, origin_type, destination_type, date
        )

        return DataclassWrapper.wrap(
            Restriction,
            self.execute(
                "get",
                "/".join(["travelsafe", "restrictions"]) + "?" + params.as_url_param(),
            ),
        )
Beispiel #19
0
 def create(self, name: str) -> CostCenterDetail:
     params = CreateCostCenterInputParams(name)
     return DataclassWrapper.wrap(
         CostCenterDetail,
         self.execute("post", "/".join(["cost_centers"]), params.to_dict()),
     )
 def get(self, id: str) -> Webhook:
     return DataclassWrapper.wrap(
         Webhook, self.execute("get", "/".join(["webhooks", id])))
 def create(self, name: str, url: str, secret: str,
            events: List[str]) -> Webhook:
     params = CreateWebhookInputParams(name, url, secret, events)
     return DataclassWrapper.wrap(
         Webhook,
         self.execute("post", "/".join(["webhooks"]), params.to_dict()))
 def get(self, serial_number: str) -> InvoiceType:
     return DataclassWrapper.wrap(
         InvoiceType,
         self.execute("get", "/".join(["invoices", serial_number])))
 def save(self) -> Webhook:
     return DataclassWrapper.wrap(
         Webhook,
         self.travelperk.patch("/".join(["webhooks", self.id]),
                               self.params.to_dict()),
     )
 def get(self) -> Trips:
     return DataclassWrapper.wrap(
         Trips,
         self.execute(
             "get", "/".join(["trips"]) + "?" + self.params.as_url_param()),
     )
 def all(self) -> WebhooksType:
     return DataclassWrapper.wrap(
         WebhooksType, self.execute("get", "/".join(["webhooks"])))
Beispiel #26
0
 def get(self, id: int) -> CostCenterDetail:
     return DataclassWrapper.wrap(
         CostCenterDetail,
         self.execute("get", "/".join(["cost_centers", id])))
Beispiel #27
0
 def all(self) -> CostCentersType:
     return DataclassWrapper.wrap(
         CostCentersType, self.execute("get", "/".join(["cost_centers"])))
 def events(self) -> List[str]:
     events = self.travelperk.get("/".join(["webhooks", "events"]))
     return [DataclassWrapper.wrap(Event, event) for event in events]