<% if cinstance.service.backend_version == "2"  %>
  <tr>
    <th>Application ID</th>
    <td><%= cinstance.application_id %></td>
  </tr>
  <%= render :partial =>'buyers/applications/keys', :locals => {:cinstance => cinstance} %>
<% elsif cinstance.service.backend_version == 'oauth' %>
  <tr>
    <th>Client ID</th>
    <td><%= cinstance.application_id %></td>
  </tr>

  <tr>
    <th>Client Secret</th>
    <td>
      <table id='keys'>
        <tr id="application_key_<%= cinstance.keys.first %>" class="key">
          <td>
            <span class="key" id="oauth_secret"><%= cinstance.keys.first %></span>
          </td>
          <td>
            <% unless cinstance.keys.empty? %>
              <%= fancy_link_to("Regenerate", regenerate_provider_admin_application_key_path(:application_id => cinstance.id, :id => cinstance.keys.first),
                                :method => :put, :class => 'delete', :remote => true, :id => 'regenerate-oauth-key')%>
            <% end %>
          </td>
        </tr>
      </table>
    </td>
  </tr>

  <tr>
    <th>Redirect URL</th>
    <td>
      <table>
        <tr class="key">
          <td>
            <span class="key"><%= cinstance.redirect_url %></span>
          </td>
          <td>
            <%= link_to("Change", edit_redirect_url_admin_buyers_application_path(cinstance),
                        :class => 'fancybox action add', 'data-autodimensions' => 'true') %>
          </td>
        </tr>
      </table>
    </td>
  </tr>

<% else %>
  <tr>
    <td colspan='2'>
      <h3><%= user_key_label(cinstance) %></h3>
      <p id="cinstance-user-key"><%= cinstance.user_key %></p>
      <% if defined?(regenerate) && regenerate %>
        <%= button_to 'Regenerate', change_user_key_admin_buyers_application_path(cinstance), :method => :put, data: {:confirm => "Are you sure?"} %>
      <% end %>
      <% if cinstance.custom_keys_enabled? and can?(:custom_key, cinstance) %>
        <%= link_to 'Set Custom Key', edit_provider_admin_application_key_path(cinstance, cinstance.user_key),
                    :class => 'fancybox action add', 'data-autodimensions' => 'true' %>
      <% end %>
    </td>
  </tr>
<% end %>
