md-notes-resource 1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +460 -0
- data/lib/md_notes.rb +45 -0
- data/lib/md_notes/api_helper.rb +289 -0
- data/lib/md_notes/client.rb +61 -0
- data/lib/md_notes/configuration.rb +157 -0
- data/lib/md_notes/controllers/base_controller.rb +49 -0
- data/lib/md_notes/controllers/o_auth_authorization_controller.rb +140 -0
- data/lib/md_notes/controllers/service_controller.rb +40 -0
- data/lib/md_notes/controllers/user_controller.rb +40 -0
- data/lib/md_notes/exceptions/api_exception.rb +20 -0
- data/lib/md_notes/exceptions/o_auth_provider_exception.rb +44 -0
- data/lib/md_notes/http/auth/o_auth2.rb +78 -0
- data/lib/md_notes/http/faraday_client.rb +70 -0
- data/lib/md_notes/http/http_call_back.rb +24 -0
- data/lib/md_notes/http/http_client.rb +104 -0
- data/lib/md_notes/http/http_method_enum.rb +13 -0
- data/lib/md_notes/http/http_request.rb +50 -0
- data/lib/md_notes/http/http_response.rb +29 -0
- data/lib/md_notes/models/base_model.rb +54 -0
- data/lib/md_notes/models/note.rb +90 -0
- data/lib/md_notes/models/o_auth_provider_error_enum.rb +39 -0
- data/lib/md_notes/models/o_auth_token.rb +92 -0
- data/lib/md_notes/models/service_status.rb +108 -0
- data/lib/md_notes/models/user.rb +81 -0
- data/lib/md_notes/utilities/file_wrapper.rb +17 -0
- metadata +151 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
# md_notes
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MdNotes
|
7
|
+
# HttpCallBack allows defining callables for pre and post API calls.
|
8
|
+
class HttpCallBack
|
9
|
+
# A controller will call this method before making an HTTP Request.
|
10
|
+
# @param [HttpRequest] The HttpRequest object which the HttpClient
|
11
|
+
# will execute.
|
12
|
+
def on_before_request(_http_request)
|
13
|
+
raise NotImplementedError, 'This method needs
|
14
|
+
to be implemented in a child class.'
|
15
|
+
end
|
16
|
+
|
17
|
+
# A controller will call this method after making an HTTP Request.
|
18
|
+
# @param [HttpResponse] The HttpReponse of the API call.
|
19
|
+
def on_after_response(_http_response)
|
20
|
+
raise NotImplementedError, 'This method needs
|
21
|
+
to be implemented in a child class.'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# md_notes
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MdNotes
|
7
|
+
# An interface for the methods that an HTTP Client must implement.
|
8
|
+
#
|
9
|
+
# This class should not be instantiated but should be used as a base class
|
10
|
+
# for HTTP Client classes.
|
11
|
+
class HttpClient
|
12
|
+
# Execute an HttpRequest when the response is expected to be a string.
|
13
|
+
# @param [HttpRequest] The HttpRequest to be executed.
|
14
|
+
def execute_as_string(_http_request)
|
15
|
+
raise NotImplementedError, 'This method needs
|
16
|
+
to be implemented in a child class.'
|
17
|
+
end
|
18
|
+
|
19
|
+
# Execute an HttpRequest when the response is expected to be binary.
|
20
|
+
# @param [HttpRequest] The HttpRequest to be executed.
|
21
|
+
def execute_as_binary(_http_request)
|
22
|
+
raise NotImplementedError, 'This method needs
|
23
|
+
to be implemented in a child class.'
|
24
|
+
end
|
25
|
+
|
26
|
+
# Converts the HTTP Response from the client to an HttpResponse object.
|
27
|
+
# @param [Dynamic] The response object received from the client.
|
28
|
+
def convert_response(_response)
|
29
|
+
raise NotImplementedError, 'This method needs
|
30
|
+
to be implemented in a child class.'
|
31
|
+
end
|
32
|
+
|
33
|
+
# Get a GET HttpRequest object.
|
34
|
+
# @param [String] The URL to send the request to.
|
35
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
36
|
+
def get(query_url,
|
37
|
+
headers: {})
|
38
|
+
HttpRequest.new(HttpMethodEnum::GET,
|
39
|
+
query_url,
|
40
|
+
headers: headers)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Get a HEAD HttpRequest object.
|
44
|
+
# @param [String] The URL to send the request to.
|
45
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
46
|
+
def head(query_url,
|
47
|
+
headers: {})
|
48
|
+
HttpRequest.new(HttpMethodEnum::HEAD,
|
49
|
+
query_url,
|
50
|
+
headers: headers)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Get a POST HttpRequest object.
|
54
|
+
# @param [String] The URL to send the request to.
|
55
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
56
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
57
|
+
def post(query_url,
|
58
|
+
headers: {},
|
59
|
+
parameters: {})
|
60
|
+
HttpRequest.new(HttpMethodEnum::POST,
|
61
|
+
query_url,
|
62
|
+
headers: headers,
|
63
|
+
parameters: parameters)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Get a PUT HttpRequest object.
|
67
|
+
# @param [String] The URL to send the request to.
|
68
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
69
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
70
|
+
def put(query_url,
|
71
|
+
headers: {},
|
72
|
+
parameters: {})
|
73
|
+
HttpRequest.new(HttpMethodEnum::PUT,
|
74
|
+
query_url,
|
75
|
+
headers: headers,
|
76
|
+
parameters: parameters)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Get a PATCH HttpRequest object.
|
80
|
+
# @param [String] The URL to send the request to.
|
81
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
82
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
83
|
+
def patch(query_url,
|
84
|
+
headers: {},
|
85
|
+
parameters: {})
|
86
|
+
HttpRequest.new(HttpMethodEnum::PATCH,
|
87
|
+
query_url,
|
88
|
+
headers: headers,
|
89
|
+
parameters: parameters)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Get a DELETE HttpRequest object.
|
93
|
+
# @param [String] The URL to send the request to.
|
94
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
95
|
+
def delete(query_url,
|
96
|
+
headers: {},
|
97
|
+
parameters: {})
|
98
|
+
HttpRequest.new(HttpMethodEnum::DELETE,
|
99
|
+
query_url,
|
100
|
+
headers: headers,
|
101
|
+
parameters: parameters)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# md_notes
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MdNotes
|
7
|
+
# HTTP Methods Enumeration.
|
8
|
+
class HttpMethodEnum
|
9
|
+
HTTPMETHODENUM = [GET = 'GET'.freeze, POST = 'POST'.freeze,
|
10
|
+
PUT = 'PUT'.freeze, PATCH = 'PATCH'.freeze,
|
11
|
+
DELETE = 'DELETE'.freeze, HEAD = 'HEAD'.freeze].freeze
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# md_notes
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MdNotes
|
7
|
+
# Represents a single Http Request.
|
8
|
+
class HttpRequest
|
9
|
+
attr_accessor :http_method, :query_url, :headers,
|
10
|
+
:parameters, :username, :password
|
11
|
+
|
12
|
+
# The constructor.
|
13
|
+
# @param [HttpMethodEnum] The HTTP method.
|
14
|
+
# @param [String] The URL to send the request to.
|
15
|
+
# @param [Hash, Optional] The headers for the HTTP Request.
|
16
|
+
# @param [Hash, Optional] The parameters for the HTTP Request.
|
17
|
+
def initialize(http_method,
|
18
|
+
query_url,
|
19
|
+
headers: {},
|
20
|
+
parameters: {})
|
21
|
+
@http_method = http_method
|
22
|
+
@query_url = query_url
|
23
|
+
@headers = headers
|
24
|
+
@parameters = parameters
|
25
|
+
end
|
26
|
+
|
27
|
+
# Add a header to the HttpRequest.
|
28
|
+
# @param [String] The name of the header.
|
29
|
+
# @param [String] The value of the header.
|
30
|
+
def add_header(name, value)
|
31
|
+
@headers[name] = value
|
32
|
+
end
|
33
|
+
|
34
|
+
# Add a parameter to the HttpRequest.
|
35
|
+
# @param [String] The name of the parameter.
|
36
|
+
# @param [String] The value of the parameter.
|
37
|
+
def add_parameter(name, value)
|
38
|
+
@parameters[name] = value
|
39
|
+
end
|
40
|
+
|
41
|
+
# Add a query parameter to the HttpRequest.
|
42
|
+
# @param [String] The name of the query parameter.
|
43
|
+
# @param [String] The value of the query parameter.
|
44
|
+
def add_query_parameter(name, value)
|
45
|
+
@query_url = APIHelper.append_url_with_query_parameters(@query_url,
|
46
|
+
name => value)
|
47
|
+
@query_url = APIHelper.clean_url(@query_url)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# md_notes
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MdNotes
|
7
|
+
# Http response received.
|
8
|
+
class HttpResponse
|
9
|
+
attr_reader :status_code, :reason_phrase, :headers, :raw_body, :request
|
10
|
+
|
11
|
+
# The constructor
|
12
|
+
# @param [Integer] The status code returned by the server.
|
13
|
+
# @param [String] The reason phrase returned by the server.
|
14
|
+
# @param [Hash] The headers sent by the server in the response.
|
15
|
+
# @param [String] The raw body of the response.
|
16
|
+
# @param [HttpRequest] The request that resulted in this response.
|
17
|
+
def initialize(status_code,
|
18
|
+
reason_phrase,
|
19
|
+
headers,
|
20
|
+
raw_body,
|
21
|
+
request)
|
22
|
+
@status_code = status_code
|
23
|
+
@reason_phrase = reason_phrase
|
24
|
+
@headers = headers
|
25
|
+
@raw_body = raw_body
|
26
|
+
@request = request
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# md_notes
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MdNotes
|
7
|
+
# Base model.
|
8
|
+
class BaseModel
|
9
|
+
# Returns a Hash representation of the current object.
|
10
|
+
def to_hash
|
11
|
+
hash = {}
|
12
|
+
instance_variables.each do |name|
|
13
|
+
value = instance_variable_get(name)
|
14
|
+
name = name[1..-1]
|
15
|
+
key = self.class.names.key?(name) ? self.class.names[name] : name
|
16
|
+
if value.instance_of? Array
|
17
|
+
hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
|
18
|
+
elsif value.instance_of? Hash
|
19
|
+
hash[key] = {}
|
20
|
+
value.each do |k, v|
|
21
|
+
hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
|
22
|
+
end
|
23
|
+
else
|
24
|
+
hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
|
25
|
+
end
|
26
|
+
end
|
27
|
+
hash
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns a JSON representation of the curent object.
|
31
|
+
def to_json(options = {})
|
32
|
+
hash = to_hash
|
33
|
+
hash.to_json(options)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Use to allow additional model properties.
|
37
|
+
def method_missing(method_sym, *arguments, &block)
|
38
|
+
method = method_sym.to_s
|
39
|
+
if method.end_with? '='
|
40
|
+
instance_variable_set(format('@%s', [method.chomp('=')]),
|
41
|
+
arguments.first)
|
42
|
+
elsif instance_variable_defined?("@#{method}") && arguments.empty?
|
43
|
+
instance_variable_get("@#{method}")
|
44
|
+
else
|
45
|
+
super
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Override for additional model properties.
|
50
|
+
def respond_to_missing?(method_sym, include_private = false)
|
51
|
+
instance_variable_defined?("@#{method_sym}") ? true : super
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# md_notes
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MdNotes
|
7
|
+
# Note Model.
|
8
|
+
class Note < BaseModel
|
9
|
+
# TODO: Write general description for this method
|
10
|
+
# @return [Long]
|
11
|
+
attr_accessor :id
|
12
|
+
|
13
|
+
# TODO: Write general description for this method
|
14
|
+
# @return [String]
|
15
|
+
attr_accessor :title
|
16
|
+
|
17
|
+
# TODO: Write general description for this method
|
18
|
+
# @return [String]
|
19
|
+
attr_accessor :body
|
20
|
+
|
21
|
+
# TODO: Write general description for this method
|
22
|
+
# @return [Long]
|
23
|
+
attr_accessor :user_id
|
24
|
+
|
25
|
+
# TODO: Write general description for this method
|
26
|
+
# @return [String]
|
27
|
+
attr_accessor :created_at
|
28
|
+
|
29
|
+
# TODO: Write general description for this method
|
30
|
+
# @return [String]
|
31
|
+
attr_accessor :updated_at
|
32
|
+
|
33
|
+
# A mapping from model property names to API property names.
|
34
|
+
def self.names
|
35
|
+
@_hash = {} if @_hash.nil?
|
36
|
+
@_hash['id'] = 'id'
|
37
|
+
@_hash['title'] = 'title'
|
38
|
+
@_hash['body'] = 'body'
|
39
|
+
@_hash['user_id'] = 'user_id'
|
40
|
+
@_hash['created_at'] = 'created_at'
|
41
|
+
@_hash['updated_at'] = 'updated_at'
|
42
|
+
@_hash
|
43
|
+
end
|
44
|
+
|
45
|
+
def initialize(id = nil,
|
46
|
+
title = nil,
|
47
|
+
body = nil,
|
48
|
+
user_id = nil,
|
49
|
+
created_at = nil,
|
50
|
+
updated_at = nil,
|
51
|
+
additional_properties = {})
|
52
|
+
@id = id
|
53
|
+
@title = title
|
54
|
+
@body = body
|
55
|
+
@user_id = user_id
|
56
|
+
@created_at = created_at
|
57
|
+
@updated_at = updated_at
|
58
|
+
|
59
|
+
# Add additional model properties to the instance.
|
60
|
+
additional_properties.each do |_name, _value|
|
61
|
+
instance_variable_set("@#{_name}", _value)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Creates an instance of the object from a hash.
|
66
|
+
def self.from_hash(hash)
|
67
|
+
return nil unless hash
|
68
|
+
|
69
|
+
# Extract variables from the hash.
|
70
|
+
id = hash['id']
|
71
|
+
title = hash['title']
|
72
|
+
body = hash['body']
|
73
|
+
user_id = hash['user_id']
|
74
|
+
created_at = hash['created_at']
|
75
|
+
updated_at = hash['updated_at']
|
76
|
+
|
77
|
+
# Clean out expected properties from Hash.
|
78
|
+
names.each_value { |k| hash.delete(k) }
|
79
|
+
|
80
|
+
# Create object from extracted values.
|
81
|
+
Note.new(id,
|
82
|
+
title,
|
83
|
+
body,
|
84
|
+
user_id,
|
85
|
+
created_at,
|
86
|
+
updated_at,
|
87
|
+
hash)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# md_notes
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MdNotes
|
7
|
+
# OAuth 2 Authorization error codes
|
8
|
+
class OAuthProviderErrorEnum
|
9
|
+
O_AUTH_PROVIDER_ERROR_ENUM = [
|
10
|
+
# The request is missing a required parameter, includes an unsupported
|
11
|
+
# parameter value (other than grant type), repeats a parameter, includes
|
12
|
+
# multiple credentials, utilizes more than one mechanism for
|
13
|
+
# authenticating the client, or is otherwise malformed.
|
14
|
+
INVALID_REQUEST = 'invalid_request'.freeze,
|
15
|
+
|
16
|
+
# Client authentication failed (e.g., unknown client, no client
|
17
|
+
# authentication included, or unsupported authentication method).
|
18
|
+
INVALID_CLIENT = 'invalid_client'.freeze,
|
19
|
+
|
20
|
+
# The provided authorization grant (e.g., authorization code, resource
|
21
|
+
# owner credentials) or refresh token is invalid, expired, revoked, does
|
22
|
+
# not match the redirection URI used in the authorization request, or was
|
23
|
+
# issued to another client.
|
24
|
+
INVALID_GRANT = 'invalid_grant'.freeze,
|
25
|
+
|
26
|
+
# The authenticated client is not authorized to use this authorization
|
27
|
+
# grant type.
|
28
|
+
UNAUTHORIZED_CLIENT = 'unauthorized_client'.freeze,
|
29
|
+
|
30
|
+
# The authorization grant type is not supported by the authorization
|
31
|
+
# server.
|
32
|
+
UNSUPPORTED_GRANT_TYPE = 'unsupported_grant_type'.freeze,
|
33
|
+
|
34
|
+
# The requested scope is invalid, unknown, malformed, or exceeds the scope
|
35
|
+
# granted by the resource owner.
|
36
|
+
INVALID_SCOPE = 'invalid_scope'.freeze
|
37
|
+
].freeze
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# md_notes
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module MdNotes
|
7
|
+
# OAuth 2 Authorization endpoint response
|
8
|
+
class OAuthToken < BaseModel
|
9
|
+
# Access token
|
10
|
+
# @return [String]
|
11
|
+
attr_accessor :access_token
|
12
|
+
|
13
|
+
# Type of access token
|
14
|
+
# @return [String]
|
15
|
+
attr_accessor :token_type
|
16
|
+
|
17
|
+
# Time in seconds before the access token expires
|
18
|
+
# @return [Long]
|
19
|
+
attr_accessor :expires_in
|
20
|
+
|
21
|
+
# List of scopes granted
|
22
|
+
# This is a space-delimited list of strings.
|
23
|
+
# @return [String]
|
24
|
+
attr_accessor :scope
|
25
|
+
|
26
|
+
# Time of token expiry as unix timestamp (UTC)
|
27
|
+
# @return [Long]
|
28
|
+
attr_accessor :expiry
|
29
|
+
|
30
|
+
# Refresh token
|
31
|
+
# Used to get a new access token when it expires.
|
32
|
+
# @return [String]
|
33
|
+
attr_accessor :refresh_token
|
34
|
+
|
35
|
+
# A mapping from model property names to API property names.
|
36
|
+
def self.names
|
37
|
+
@_hash = {} if @_hash.nil?
|
38
|
+
@_hash['access_token'] = 'access_token'
|
39
|
+
@_hash['token_type'] = 'token_type'
|
40
|
+
@_hash['expires_in'] = 'expires_in'
|
41
|
+
@_hash['scope'] = 'scope'
|
42
|
+
@_hash['expiry'] = 'expiry'
|
43
|
+
@_hash['refresh_token'] = 'refresh_token'
|
44
|
+
@_hash
|
45
|
+
end
|
46
|
+
|
47
|
+
def initialize(access_token = nil,
|
48
|
+
token_type = nil,
|
49
|
+
expires_in = nil,
|
50
|
+
scope = nil,
|
51
|
+
expiry = nil,
|
52
|
+
refresh_token = nil,
|
53
|
+
additional_properties = {})
|
54
|
+
@access_token = access_token
|
55
|
+
@token_type = token_type
|
56
|
+
@expires_in = expires_in
|
57
|
+
@scope = scope
|
58
|
+
@expiry = expiry
|
59
|
+
@refresh_token = refresh_token
|
60
|
+
|
61
|
+
# Add additional model properties to the instance.
|
62
|
+
additional_properties.each do |_name, _value|
|
63
|
+
instance_variable_set("@#{_name}", _value)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Creates an instance of the object from a hash.
|
68
|
+
def self.from_hash(hash)
|
69
|
+
return nil unless hash
|
70
|
+
|
71
|
+
# Extract variables from the hash.
|
72
|
+
access_token = hash['access_token']
|
73
|
+
token_type = hash['token_type']
|
74
|
+
expires_in = hash['expires_in']
|
75
|
+
scope = hash['scope']
|
76
|
+
expiry = hash['expiry']
|
77
|
+
refresh_token = hash['refresh_token']
|
78
|
+
|
79
|
+
# Clean out expected properties from Hash.
|
80
|
+
names.each_value { |k| hash.delete(k) }
|
81
|
+
|
82
|
+
# Create object from extracted values.
|
83
|
+
OAuthToken.new(access_token,
|
84
|
+
token_type,
|
85
|
+
expires_in,
|
86
|
+
scope,
|
87
|
+
expiry,
|
88
|
+
refresh_token,
|
89
|
+
hash)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|