-
Notifications
You must be signed in to change notification settings - Fork 25
/
opml.go
107 lines (93 loc) · 2.77 KB
/
opml.go
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Code generated by goagen v1.4.3, DO NOT EDIT.
//
// API "feedpushr": opml Resource Client
//
// Command:
// $ goagen
// --design=github.com/ncarlier/feedpushr/v3/design
// --out=/home/nicolas/workspace/feedpushr/autogen
// --version=v1.4.3
package client
import (
"context"
"fmt"
"net/http"
"net/url"
"strconv"
)
// GetOpmlPath computes a request path to the get action of opml.
func GetOpmlPath() string {
return fmt.Sprintf("/v2/opml")
}
// Get all feeds as an OPML format
func (c *Client) GetOpml(ctx context.Context, path string) (*http.Response, error) {
req, err := c.NewGetOpmlRequest(ctx, path)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewGetOpmlRequest create the request corresponding to the get action endpoint of the opml resource.
func (c *Client) NewGetOpmlRequest(ctx context.Context, path string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}
// StatusOpmlPath computes a request path to the status action of opml.
func StatusOpmlPath(id int) string {
param0 := strconv.Itoa(id)
return fmt.Sprintf("/v2/opml/status/%s", param0)
}
// Get OPML import status
func (c *Client) StatusOpml(ctx context.Context, path string) (*http.Response, error) {
req, err := c.NewStatusOpmlRequest(ctx, path)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewStatusOpmlRequest create the request corresponding to the status action endpoint of the opml resource.
func (c *Client) NewStatusOpmlRequest(ctx context.Context, path string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}
// UploadOpmlPath computes a request path to the upload action of opml.
func UploadOpmlPath() string {
return fmt.Sprintf("/v2/opml")
}
// Upload an OPML file to create feeds
func (c *Client) UploadOpml(ctx context.Context, path string) (*http.Response, error) {
req, err := c.NewUploadOpmlRequest(ctx, path)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewUploadOpmlRequest create the request corresponding to the upload action endpoint of the opml resource.
func (c *Client) NewUploadOpmlRequest(ctx context.Context, path string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequestWithContext(ctx, "POST", u.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}