| Conditions | 6 |
| Total Lines | 30 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 6.0131 |
| Changes | 0 | ||
| 1 | package devto |
||
| 40 | func NewClient(ctx context.Context, conf *Config, bc httpClient, bu string) (dev *Client, err error) { |
||
| 41 | 1 | if bc == nil { |
|
| 42 | 1 | bc = http.DefaultClient |
|
| 43 | } |
||
| 44 | |||
| 45 | 1 | if ctx == nil { |
|
| 46 | 1 | ctx = context.Background() |
|
| 47 | } |
||
| 48 | |||
| 49 | 1 | if conf == nil { |
|
| 50 | 1 | return nil, ErrMissingConfig |
|
| 51 | } |
||
| 52 | |||
| 53 | 1 | if bu == "" { |
|
| 54 | 1 | bu = BaseURL |
|
| 55 | } |
||
| 56 | |||
| 57 | 1 | u, err := url.Parse(bu) |
|
| 58 | 1 | if err != nil { |
|
| 59 | return nil, err |
||
| 60 | } |
||
| 61 | |||
| 62 | 1 | c := &Client{ |
|
| 63 | Context: ctx, |
||
| 64 | BaseURL: u, |
||
| 65 | HTTPClient: bc, |
||
| 66 | Config: conf, |
||
| 67 | } |
||
| 68 | 1 | c.Articles = &ArticlesResource{API: c} |
|
| 69 | 1 | return c, nil |
|
| 70 | } |
||
| 85 |