File: request.py

package info (click to toggle)
chargebee-python 1.6.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 484 kB
  • sloc: python: 1,008; makefile: 6; sh: 3
file content (32 lines) | stat: -rw-r--r-- 1,000 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import urllib
from chargebee import util, http_request
from chargebee.main import ChargeBee
from chargebee import compat

def send(method, url, params=None, env=None, headers=None):
    if params is None:
        params = {}

    env = env or ChargeBee.default_env

    ser_params = util.serialize(params)

    response = http_request.request(method, url, env, ser_params, headers)

    from chargebee.result import Result
    from chargebee.list_result import ListResult
    if 'list' in response:
        return ListResult(response['list'], response.get('next_offset', None))
    return Result(response)

def uri_path(*paths):
    url = ""
    for path in paths:
        if path == None or len(str(path).strip()) < 1 :
             raise Exception("Id is None or empty")
        if compat.py_major_v >= 3:          
             url = url + "/" +  urllib.parse.quote(str(path).strip()) 
        else:
             url =  url + "/" + urllib.quote(str(util.get_val(path)))
    return url