Class: OSDNClient::DefaultApi

Inherits:
Object
  • Object
show all
Defined in:
lib/osdn-client/api/default_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ DefaultApi

Returns a new instance of DefaultApi.



30
31
32
# File 'lib/osdn-client/api/default_api.rb', line 30

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



28
29
30
# File 'lib/osdn-client/api/default_api.rb', line 28

def api_client
  @api_client
end

Instance Method Details

#ping(opts = {}) ⇒ Pong

return pong for test

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



38
39
40
41
# File 'lib/osdn-client/api/default_api.rb', line 38

def ping(opts = {})
  data, _status_code, _headers = ping_with_http_info(opts)
  return data
end

#ping_with_http_info(opts = {}) ⇒ Array<(Pong, Fixnum, Hash)>

return pong for test

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Pong, Fixnum, Hash)>)

    Pong data, response status code and response headers



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
# File 'lib/osdn-client/api/default_api.rb', line 47

def ping_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: DefaultApi.ping ..."
  end
  # resource path
  local_var_path = "/ping".sub('{format}','json')

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}

  # HTTP header 'Accept' (if needed)
  local_header_accept = []
  local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

  # HTTP header 'Content-Type'
  local_header_content_type = ['application/x-www-form-urlencoded']
  header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['oauth2-code', 'oauth2-implicit']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'Pong')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#ping\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#token(client_id, client_secret, opts = {}) ⇒ Token

Get access token by access code.

Parameters:

  • client_id

    Your application ID

  • client_secret

    Your application secret (key)

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :grant_type (String)

    &quot;authorization_code&quot; or &quot;refresh_token&quot; (default to authorization_code)

  • :code (String)

    Set auth code issued by osdn.net/account/oauth2ui/authorize for grant_type&#x3D;authorization_code

  • :refresh_token (String)

    Set refresh token to update access token.

Returns:



96
97
98
99
# File 'lib/osdn-client/api/default_api.rb', line 96

def token(client_id, client_secret, opts = {})
  data, _status_code, _headers = token_with_http_info(client_id, client_secret, opts)
  return data
end

#token_with_http_info(client_id, client_secret, opts = {}) ⇒ Array<(Token, Fixnum, Hash)>

Get access token by access code.

Parameters:

  • client_id

    Your application ID

  • client_secret

    Your application secret (key)

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :grant_type (String)

    &quot;authorization_code&quot; or &quot;refresh_token&quot;

  • :code (String)

    Set auth code issued by osdn.net/account/oauth2ui/authorize for grant_type&#x3D;authorization_code

  • :refresh_token (String)

    Set refresh token to update access token.

Returns:

  • (Array<(Token, Fixnum, Hash)>)

    Token data, response status code and response headers



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/osdn-client/api/default_api.rb', line 110

def token_with_http_info(client_id, client_secret, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: DefaultApi.token ..."
  end
  # verify the required parameter 'client_id' is set
  fail ArgumentError, "Missing the required parameter 'client_id' when calling DefaultApi.token" if client_id.nil?
  # verify the required parameter 'client_secret' is set
  fail ArgumentError, "Missing the required parameter 'client_secret' when calling DefaultApi.token" if client_secret.nil?
  # resource path
  local_var_path = "/token".sub('{format}','json')

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}

  # HTTP header 'Accept' (if needed)
  local_header_accept = []
  local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result

  # HTTP header 'Content-Type'
  local_header_content_type = ['application/x-www-form-urlencoded']
  header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)

  # form parameters
  form_params = {}
  form_params["client_id"] = client_id
  form_params["client_secret"] = client_secret
  form_params["grant_type"] = opts[:'grant_type'] if !opts[:'grant_type'].nil?
  form_params["code"] = opts[:'code'] if !opts[:'code'].nil?
  form_params["refresh_token"] = opts[:'refresh_token'] if !opts[:'refresh_token'].nil?

  # http body (model)
  post_body = nil
  auth_names = []
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'Token')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DefaultApi#token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end