├── .gitignore ├── .rspec ├── .travis.yml ├── CODE_OF_CONDUCT.md ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── bin ├── console └── setup ├── config ├── .keep └── test-oauth-credentials.json ├── lib ├── wp_api_client.rb └── wp_api_client │ ├── client.rb │ ├── collection.rb │ ├── concurrent_client.rb │ ├── configuration.rb │ ├── connection.rb │ ├── entities │ ├── base.rb │ ├── error.rb │ ├── image.rb │ ├── meta.rb │ ├── post.rb │ ├── taxonomy.rb │ ├── term.rb │ ├── types.rb │ └── user.rb │ ├── relationship.rb │ └── version.rb ├── spec ├── cassettes │ ├── 4.4 │ │ ├── concurrency.yml │ │ ├── custom_post_type_collection.yml │ │ ├── oauth_test.yml │ │ ├── single_image.yml │ │ ├── single_post.yml │ │ ├── single_post_auth.yml │ │ ├── single_taxonomy.yml │ │ ├── single_term.yml │ │ └── single_user.yml │ ├── 4.5.3 │ │ ├── concurrency.yml │ │ ├── custom_post_type_collection.yml │ │ ├── oauth_test.yml │ │ ├── single_image.yml │ │ ├── single_post.yml │ │ ├── single_post_auth.yml │ │ ├── single_taxonomy.yml │ │ ├── single_term.yml │ │ └── single_user.yml │ ├── 4.5.3_b13 │ │ ├── concurrency.yml │ │ ├── custom_post_type_collection.yml │ │ ├── oauth_test.yml │ │ ├── single_image.yml │ │ ├── single_post.yml │ │ ├── single_post_auth.yml │ │ ├── single_taxonomy.yml │ │ ├── single_term.yml │ │ └── single_user.yml │ ├── 4.5 │ │ ├── concurrency.yml │ │ ├── custom_post_type_collection.yml │ │ ├── oauth_test.yml │ │ ├── single_image.yml │ │ ├── single_post.yml │ │ ├── single_post_auth.yml │ │ ├── single_taxonomy.yml │ │ ├── single_term.yml │ │ └── single_user.yml │ ├── 4.7.2 │ │ ├── concurrency.yml │ │ ├── custom_post_type_collection.yml │ │ ├── oauth_test.yml │ │ ├── single_image.yml │ │ ├── single_post.yml │ │ ├── single_post_auth.yml │ │ ├── single_taxonomy.yml │ │ ├── single_term.yml │ │ └── single_user.yml │ └── 4.7 │ │ ├── concurrency.yml │ │ ├── custom_post_type_collection.yml │ │ ├── oauth_test.yml │ │ ├── single_image.yml │ │ ├── single_post.yml │ │ ├── single_post_auth.yml │ │ ├── single_taxonomy.yml │ │ ├── single_term.yml │ │ └── single_user.yml ├── collection_spec.rb ├── connection_spec.rb ├── entity_spec.rb ├── error_spec.rb ├── media_spec.rb ├── post_spec.rb ├── relationships_spec.rb ├── spec_helper.rb ├── support │ └── matchers.rb ├── taxonomy_spec.rb ├── term_spec.rb ├── user_spec.rb ├── wp_api_client_spec.rb └── wp_api_configuration_spec.rb └── wp_api_client.gemspec /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | /config/oauth.json 11 | *.gem 12 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --color 3 | --require spec_helper 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 2.3.0 4 | before_install: gem install bundler -v 1.11.2 5 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, and in the interest of 4 | fostering an open and welcoming community, we pledge to respect all people who 5 | contribute through reporting issues, posting feature requests, updating 6 | documentation, submitting pull requests or patches, and other activities. 7 | 8 | We are committed to making participation in this project a harassment-free 9 | experience for everyone, regardless of level of experience, gender, gender 10 | identity and expression, sexual orientation, disability, personal appearance, 11 | body size, race, ethnicity, age, religion, or nationality. 12 | 13 | Examples of unacceptable behavior by participants include: 14 | 15 | * The use of sexualized language or imagery 16 | * Personal attacks 17 | * Trolling or insulting/derogatory comments 18 | * Public or private harassment 19 | * Publishing other's private information, such as physical or electronic 20 | addresses, without explicit permission 21 | * Other unethical or unprofessional conduct 22 | 23 | Project maintainers have the right and responsibility to remove, edit, or 24 | reject comments, commits, code, wiki edits, issues, and other contributions 25 | that are not aligned to this Code of Conduct, or to ban temporarily or 26 | permanently any contributor for other behaviors that they deem inappropriate, 27 | threatening, offensive, or harmful. 28 | 29 | By adopting this Code of Conduct, project maintainers commit themselves to 30 | fairly and consistently applying these principles to every aspect of managing 31 | this project. Project maintainers who do not follow or enforce the Code of 32 | Conduct may be permanently removed from the project team. 33 | 34 | This code of conduct applies both within project spaces and in public spaces 35 | when an individual is representing the project or its community. 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 38 | reported by contacting a project maintainer at duncanjbrown@gmail.com. All 39 | complaints will be reviewed and investigated and will result in a response that 40 | is deemed necessary and appropriate to the circumstances. Maintainers are 41 | obligated to maintain confidentiality with regard to the reporter of an 42 | incident. 43 | 44 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 45 | version 1.3.0, available at 46 | [http://contributor-covenant.org/version/1/3/0/][version] 47 | 48 | [homepage]: http://contributor-covenant.org 49 | [version]: http://contributor-covenant.org/version/1/3/0/ -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # A sample Gemfile 2 | source "https://rubygems.org" 3 | gemspec 4 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Duncan Brown 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🚨 This gem is unmaintained! 2 | 3 | _11 Feb 2021_ 4 | 5 | I don't work with WordPress any more. If you would like to take over maintenance, please open an issue! 6 | 7 | 8 | 9 | ## A read-only Ruby client for WP-API v2 10 | 11 | This unambitious client provides read-only access for WP-API v2. 12 | 13 | It supports authentication via OAuth or Basic Auth. 14 | 15 | It can make concurrent requests. 16 | 17 | It does not support update or create actions. Or comments. 18 | 19 | It requires **Ruby 2.3** and is tested against the following WordPress 20 | versions. 21 | 22 | - 4.4 23 | - 4.5 (WP-API 2.0b12) 24 | - 4.5.3 (WP-API 2.0b13) 25 | - 4.7 26 | - 4.7.2 27 | 28 | **NB** If you would like to use **2.0beta13** and up _and_ access post metadata, 29 | read the _postmeta_ section in _Testing and Compatibility_, below. 30 | 31 | ## Installation 32 | 33 | ```ruby 34 | gem install wp-api-client 35 | ``` 36 | 37 | And 38 | 39 | ```ruby 40 | require 'wp_api_client' 41 | ``` 42 | 43 | ## Usage examples 44 | 45 | #### Set up the client and get some posts 46 | 47 | ```ruby 48 | # create a client 49 | 50 | WpApiClient.configure do |api_client| 51 | api_client.endpoint = 'http://example.com/wp-json/wp/v2' 52 | end 53 | 54 | @api = WpApiClient.get_client 55 | 56 | # get some posts 57 | posts = @api.get('custom_post_type/') # or "posts/" etc 58 | # => #2... 67 | 68 | post = @api.get("posts/1") 69 | author = post.author 70 | # => #2... 71 | ``` 72 | 73 | #### Navigate between posts, terms and taxonomies 74 | 75 | ```ruby 76 | term.taxonomy 77 | # => #"Custom taxonomy"... 78 | 79 | term.posts 80 | # => # # 10 106 | 107 | posts.total_available 108 | # => 100 109 | 110 | next_page = @api.get(posts.next_page) 111 | # => # #queen ) { 140 | $data->add_link( 141 | 'http://api.myuniqueuri.com/marriage', 142 | rest_url( '/wp/v2/person/'.$king->queen ), 143 | ['embeddable' => true] 144 | ); 145 | } 146 | return $data; 147 | }, 10, 2); 148 | ``` 149 | 150 | This will cause the `http://api.myuniqueuri.com/marriage` relation to be reflected 151 | in your `_links` property when you call up the King from the REST API. 152 | 153 | But you'll get an error if you try to query this relationship using the client. 154 | 155 | ```ruby 156 | king = @api.get('person/1') 157 | queen = king.relations("http://api.myuniqueuri.com/marriage").first 158 | # => throws WpApiClient::RelationNotDefined 159 | ``` 160 | 161 | The solution is to register the relationship on configuration: 162 | 163 | ```ruby 164 | WpApiClient.configure do |c| 165 | c.define_mapping("http://api.myuniqueuri.com/marriage", :post) 166 | end 167 | 168 | ... 169 | 170 | king = @api.get('person/1') 171 | queen = king.relations("http://api.myuniqueuri.com/marriage").first 172 | # => #2... 173 | ``` 174 | 175 | There is currently support for `:post_type`, `:post`, `:term`, `:user` and `:meta` (key/value) relations. 176 | 177 | #### Loading a taxonomy via a slug 178 | 179 | WP-API returns an array even if there's only one result, so you need to be careful here 180 | 181 | ```ruby 182 | term = @api.get('custom_taxonomy', slug: 'term_one').first 183 | taxonomy_name = term.taxonomy.name 184 | posts = term.posts 185 | ``` 186 | 187 | #### OAuth 188 | 189 | Provide a symbol-keyed hash of `token`, `token_secret`, `consumer_key` and `consumer_secret` on configuration. 190 | 191 | ```ruby 192 | WpApiClient.configure do |api_client| 193 | api_client.oauth_credentials = oauth_credentials_hash 194 | end 195 | 196 | client = WpApiClient.get_client 197 | ``` 198 | 199 | #### Basic Auth 200 | 201 | Provide a symbol-keyed hash of `username` and `password` on configuration. 202 | 203 | ```ruby 204 | WpApiClient.configure do |api_client| 205 | api_client.basic_auth = {username: 'miles', password: 'smile'} 206 | end 207 | 208 | client = WpApiClient.get_client 209 | ``` 210 | 211 | ## Concurrency 212 | 213 | WP-API is _slow_: a typical request takes 0.5s. To mitigate this, I recommend 214 | caching all your responses sensibly, and when you need to fetch, do so concurrently 215 | as far as is possible. 216 | 217 | ```ruby 218 | results = [] 219 | client.concurrently do |api| 220 | results << api.get('post/1') 221 | results << api.get('post/2') 222 | results << api.get('post/3') 223 | end 224 | results 225 | # => [#, #] 226 | ``` 227 | 228 | ## Testing and compatibility 229 | 230 | This library comes with VCR cassettes recorded against a local WP installation. 231 | 232 | If you want to make your own VCR cassettes, use [these scripts](https://github.com/duncanjbrown/WP-REST-Test). 233 | 234 | To run the tests, invoke `rspec`. 235 | 236 | The repo contains cassettes built from different versions of WP. To run against 237 | these cassettes specify WP_VERSION at the CLI. 238 | 239 | ```sh 240 | WP_VERSION=4.4 rspec 241 | WP_VERSION=4.5 rspec 242 | # etc 243 | ``` 244 | 245 | ### Postmeta 246 | 247 | Metadata discovery was removed from WP-API in 2.0 beta-13 and you 248 | need to restore it manually. [More details](https://github.com/WP-API/wp-api-meta-endpoints/issues/12). 249 | 250 | ## Structure 251 | 252 | ### Public Objects 253 | 254 | #### `WpApiClient::Client` 255 | 256 | Accepts a `WpApiClient::Connection` and exposes a `#get` method. 257 | 258 | Pass a URL into `#get` and it will do its best to return usable data. 259 | 260 | The second parameter accepts an optional hash of query params. 261 | 262 | #### `WpApiClient::Connection` 263 | 264 | Initialize with an API endpoint like `http://localhost:8080/wp-json/wp/v2`, then 265 | pass into a new client. Faraday options might be pulled out of here in the future. 266 | 267 | ### Internal Objects 268 | 269 | #### `WpApiClient::Collection` 270 | 271 | Wraps a set of `WpApiClient::Entities` in an `Enumerable` interface and provides `next_page` 272 | and `previous_page` methods. Pass these into `@api` and it will give you back the 273 | data you want 274 | 275 | ```ruby 276 | next_page = @api.get(posts.next_page) 277 | # => # :spec 7 | -------------------------------------------------------------------------------- /bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require "bundler/setup" 4 | require "wp_api_client" 5 | 6 | # You can add fixtures and/or initialization code here to make experimenting 7 | # with your gem easier. You can also use a different console, if you like. 8 | 9 | # (If you use this, don't forget to add pry to your Gemfile!) 10 | # require "pry" 11 | # Pry.start 12 | 13 | require "irb" 14 | IRB.start 15 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | set -vx 5 | 6 | bundle install 7 | 8 | # Do any other automated setup that you need to do here 9 | -------------------------------------------------------------------------------- /config/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/duncanjbrown/wp-api-client/01b3671447732d06e8e472db8c89dd0e7b925a4b/config/.keep -------------------------------------------------------------------------------- /config/test-oauth-credentials.json: -------------------------------------------------------------------------------- 1 | {"consumer_key":"DJyagPXmjMxO","consumer_secret":"h1gEQ4H0gd85uSR44XjWxgqwWaSOTjsJ6BBQjtkbq00TLYJF","token":"8w2Q6IJj63OB01FmNlu6WA5A","token_secret":"UIZKlUAQOBzTLuosshhQvirAZHtGfpBvDjdQCjAlkuME68C5"} 2 | -------------------------------------------------------------------------------- /lib/wp_api_client.rb: -------------------------------------------------------------------------------- 1 | require "ostruct" 2 | 3 | require "wp_api_client/version" 4 | require "wp_api_client/configuration" 5 | 6 | require "wp_api_client/entities/base" 7 | 8 | require "wp_api_client/entities/user" 9 | require "wp_api_client/entities/post" 10 | require "wp_api_client/entities/meta" 11 | require "wp_api_client/entities/taxonomy" 12 | require "wp_api_client/entities/term" 13 | require "wp_api_client/entities/image" 14 | require "wp_api_client/entities/error" 15 | require "wp_api_client/entities/types" 16 | 17 | require "wp_api_client/client" 18 | require "wp_api_client/concurrent_client" 19 | require "wp_api_client/connection" 20 | require "wp_api_client/collection" 21 | require "wp_api_client/relationship" 22 | 23 | module WpApiClient 24 | 25 | def self.get_client 26 | @client ||= Client.new(Connection.new(configuration)) 27 | end 28 | 29 | # for tests 30 | def self.reset! 31 | @client = nil 32 | end 33 | 34 | class RelationNotDefined < StandardError; end 35 | class ErrorResponse < StandardError 36 | 37 | attr_reader :error 38 | attr_reader :status 39 | 40 | def initialize(json) 41 | @error = OpenStruct.new(json) 42 | @status = @error.data["status"] 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/wp_api_client/client.rb: -------------------------------------------------------------------------------- 1 | module WpApiClient 2 | class Client 3 | 4 | def initialize(connection) 5 | @connection = connection 6 | end 7 | 8 | def get(url, params = {}) 9 | if @concurrent_client 10 | @concurrent_client.get(api_path_from(url), params) 11 | else 12 | response = @connection.get(api_path_from(url), params) 13 | @headers = response.headers 14 | native_representation_of response.body 15 | end 16 | end 17 | 18 | def concurrently 19 | @concurrent_client ||= ConcurrentClient.new(@connection) 20 | yield @concurrent_client 21 | result = @concurrent_client.run 22 | @concurrent_client = nil 23 | result 24 | end 25 | 26 | private 27 | 28 | def api_path_from(url) 29 | url.split('wp/v2/').last 30 | end 31 | 32 | # Take the API response and figure out what it is 33 | def native_representation_of(response_body) 34 | # Do we have a collection of objects? 35 | if response_body.is_a? Array 36 | WpApiClient::Collection.new(response_body, @headers) 37 | else 38 | WpApiClient::Entities::Base.build(response_body) 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /lib/wp_api_client/collection.rb: -------------------------------------------------------------------------------- 1 | module WpApiClient 2 | class Collection 3 | include Enumerable 4 | 5 | attr_accessor :resources, :total_available 6 | 7 | def initialize(resources, headers = nil) 8 | resources = [resources] unless resources.is_a? Array 9 | @resources = resources.map { |object| WpApiClient::Entities::Base.build(object) } 10 | if headers 11 | @links = parse_link_header(headers['Link']) 12 | @total_available = headers['X-WP-TOTAL'].to_i 13 | end 14 | end 15 | 16 | def each(&block) 17 | @resources.each{|p| block.call(p)} 18 | end 19 | 20 | def next_page 21 | @links[:next] && @links[:next] 22 | end 23 | 24 | def previous_page 25 | @links[:prev] && @links[:prev] 26 | end 27 | 28 | def method_missing(method, *args) 29 | @resources.send(method, *args) 30 | end 31 | 32 | private 33 | 34 | # https://www.snip2code.com/Snippet/71914/Parse-link-headers-from-Github-API-in-Ru 35 | def parse_link_header(header, params={}) 36 | links = Hash.new 37 | return links unless header 38 | parts = header.split(',') 39 | parts.each do |part, index| 40 | section = part.split(';') 41 | url = section[0][/<(.*)>/,1] 42 | name = section[1][/rel="(.*)"/,1].to_sym 43 | links[name] = url 44 | end 45 | return links 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /lib/wp_api_client/concurrent_client.rb: -------------------------------------------------------------------------------- 1 | module WpApiClient 2 | class ConcurrentClient < Client 3 | 4 | def get(url, params = {}) 5 | @queue ||= [] 6 | @queue << [api_path_from(url), params] 7 | end 8 | 9 | def run 10 | responses = @connection.get_concurrently(@queue) 11 | responses.map { |r| native_representation_of(r.body) } 12 | end 13 | 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/wp_api_client/configuration.rb: -------------------------------------------------------------------------------- 1 | module WpApiClient 2 | 3 | class << self 4 | attr_writer :configuration 5 | end 6 | 7 | def self.configuration 8 | @configuration ||= Configuration.new 9 | end 10 | 11 | def self.configure 12 | yield(configuration) 13 | end 14 | 15 | def self.reset 16 | @configuration = Configuration.new 17 | end 18 | 19 | class Configuration 20 | attr_accessor :endpoint 21 | attr_accessor :embed 22 | attr_accessor :oauth_credentials 23 | attr_accessor :debug 24 | attr_accessor :cache 25 | attr_accessor :basic_auth 26 | attr_accessor :proxy 27 | 28 | def initialize 29 | @endpoint = 'http://localhost:8080/wp-json/wp/v2' 30 | @embed = true 31 | end 32 | 33 | def define_mapping(relation, type) 34 | WpApiClient::Relationship.define(relation, type) 35 | end 36 | 37 | def request_params 38 | params = {} 39 | if @embed 40 | params[:_embed] = true 41 | end 42 | params 43 | end 44 | 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /lib/wp_api_client/connection.rb: -------------------------------------------------------------------------------- 1 | require 'faraday' 2 | require 'faraday_middleware' 3 | require 'faraday-http-cache' 4 | require 'typhoeus' 5 | require 'typhoeus/adapters/faraday' 6 | 7 | module WpApiClient 8 | class Connection 9 | 10 | attr_accessor :headers 11 | attr_reader :concurrent 12 | 13 | def initialize(configuration) 14 | @configuration = configuration 15 | @queue = [] 16 | @conn = Faraday.new(url: configuration.endpoint) do |faraday| 17 | 18 | if configuration.oauth_credentials 19 | faraday.use FaradayMiddleware::OAuth, configuration.oauth_credentials 20 | end 21 | 22 | if configuration.basic_auth 23 | faraday.basic_auth(configuration.basic_auth[:username], configuration.basic_auth[:password]) 24 | end 25 | 26 | if configuration.debug 27 | faraday.response :logger 28 | faraday.use :instrumentation 29 | end 30 | 31 | if configuration.cache 32 | faraday.use :http_cache, store: configuration.cache, shared_cache: false 33 | end 34 | 35 | if configuration.proxy 36 | faraday.proxy configuration.proxy 37 | end 38 | 39 | faraday.use Faraday::Response::RaiseError 40 | faraday.response :json, :content_type => /\bjson$/ 41 | faraday.adapter :typhoeus 42 | end 43 | end 44 | 45 | # translate requests into wp-api urls 46 | def get(url, params = {}) 47 | @conn.get url, parse_params(params) 48 | end 49 | 50 | # requests come in as url/params pairs 51 | def get_concurrently(requests) 52 | responses = [] 53 | @conn.in_parallel do 54 | requests.map do |r| 55 | responses << get(r[0], r[1]) 56 | end 57 | end 58 | responses 59 | end 60 | 61 | private 62 | 63 | def parse_params(params) 64 | params = @configuration.request_params.merge(params) 65 | # if _embed is present at all it will have the effect of embedding — 66 | # even if it's set to "false" 67 | if params[:_embed] == false 68 | params.delete(:_embed) 69 | end 70 | params 71 | end 72 | 73 | 74 | end 75 | end 76 | -------------------------------------------------------------------------------- /lib/wp_api_client/entities/base.rb: -------------------------------------------------------------------------------- 1 | require 'open-uri' 2 | require 'ostruct' 3 | 4 | module WpApiClient 5 | module Entities 6 | class Base 7 | attr_reader :resource 8 | 9 | def self.build(resource) 10 | raise Exception if resource.nil? 11 | type = WpApiClient::Entities::Types.find { |type| type.represents?(resource) } 12 | type.new(resource) 13 | end 14 | 15 | def initialize(resource) 16 | unless resource.is_a? Hash or resource.is_a? OpenStruct 17 | raise ArgumentError.new('Tried to initialize a WP-API resource with something other than a Hash') 18 | end 19 | @resource = OpenStruct.new(resource) 20 | end 21 | 22 | def links 23 | resource["_links"] 24 | end 25 | 26 | def relations(relation, relation_to_return = nil) 27 | relationship = Relationship.new(@resource, relation) 28 | relations = relationship.get_relations 29 | if relation_to_return 30 | relations[relation_to_return] 31 | else 32 | relations 33 | end 34 | end 35 | 36 | def method_missing(method, *args) 37 | @resource.send(method, *args) 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/wp_api_client/entities/error.rb: -------------------------------------------------------------------------------- 1 | module WpApiClient 2 | module Entities 3 | class Error 4 | 5 | def self.represents?(json) 6 | json.key?("code") and json.key?("message") 7 | end 8 | 9 | def initialize(json) 10 | raise WpApiClient::ErrorResponse.new(json) 11 | end 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/wp_api_client/entities/image.rb: -------------------------------------------------------------------------------- 1 | module WpApiClient 2 | module Entities 3 | class Image < Base 4 | alias :image :resource 5 | 6 | def self.represents?(json) 7 | json["media_type"] and json["media_type"] == 'image' 8 | end 9 | 10 | def sizes(size = :full) 11 | image.dig("media_details", "sizes", size.to_s, "source_url") 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/wp_api_client/entities/meta.rb: -------------------------------------------------------------------------------- 1 | module WpApiClient 2 | module Entities 3 | class Meta < Base 4 | alias :meta :resource 5 | 6 | def self.represents?(json) 7 | json["key"] and json["value"] 8 | end 9 | 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/wp_api_client/entities/post.rb: -------------------------------------------------------------------------------- 1 | module WpApiClient 2 | module Entities 3 | class Post < Base 4 | alias :post :resource 5 | 6 | def self.represents?(json) 7 | json.dig("_links", "about") and json["_links"]["about"].first["href"] =~ /wp\/v2\/types/ 8 | end 9 | 10 | def title 11 | post["title"]["rendered"] 12 | end 13 | 14 | def date 15 | Time.parse(post["date_gmt"]) if post["date_gmt"] 16 | end 17 | 18 | def content 19 | post["content"]["rendered"] 20 | end 21 | 22 | def excerpt 23 | post["excerpt"]["rendered"] 24 | end 25 | 26 | def terms(taxonomy = nil) 27 | relations("https://api.w.org/term", taxonomy) 28 | end 29 | 30 | def author 31 | relations("author") 32 | end 33 | 34 | def meta(key = nil) 35 | @meta ||= relations("https://api.w.org/meta") 36 | 37 | if key 38 | @meta[key.to_s] 39 | else 40 | @meta 41 | end 42 | end 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/wp_api_client/entities/taxonomy.rb: -------------------------------------------------------------------------------- 1 | module WpApiClient 2 | module Entities 3 | class Taxonomy < Base 4 | alias :taxonomy :resource 5 | 6 | def self.represents?(json) 7 | !json.dig("hierarchical").nil? 8 | end 9 | 10 | def terms 11 | relations("https://api.w.org/items") 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/wp_api_client/entities/term.rb: -------------------------------------------------------------------------------- 1 | module WpApiClient 2 | module Entities 3 | class Term < Base 4 | alias :term :resource 5 | 6 | def self.represents?(json) 7 | json.dig("_links", "about") and json["_links"]["about"].first["href"] =~ /wp\/v2\/taxonomies/ 8 | end 9 | 10 | def taxonomy 11 | WpApiClient.get_client.get(links["about"].first["href"]) 12 | end 13 | 14 | def posts(post_type = nil) 15 | relations("http://api.w.org/v2/post_type", post_type) 16 | end 17 | 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/wp_api_client/entities/types.rb: -------------------------------------------------------------------------------- 1 | module WpApiClient 2 | module Entities 3 | Types = [ 4 | User, 5 | Image, 6 | Post, 7 | Meta, 8 | Term, 9 | Taxonomy, 10 | Error 11 | ] 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /lib/wp_api_client/entities/user.rb: -------------------------------------------------------------------------------- 1 | module WpApiClient 2 | module Entities 3 | class User < Base 4 | alias :user :resource 5 | 6 | def self.represents?(json) 7 | json.dig('_links', 'collection') and json['_links']['collection'].first['href'] =~ /wp\/v2\/users/ 8 | end 9 | 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/wp_api_client/relationship.rb: -------------------------------------------------------------------------------- 1 | require 'open-uri' 2 | 3 | module WpApiClient 4 | class Relationship 5 | 6 | class << self 7 | attr_writer :mappings 8 | 9 | def mappings 10 | @mappings ||= default_mappings 11 | end 12 | 13 | def define(relation, type) 14 | mappings[relation] = type 15 | end 16 | 17 | def default_mappings 18 | { 19 | "https://api.w.org/term" => :term, 20 | "https://api.w.org/items" => :terms, 21 | "http://api.w.org/v2/post_type" => :post_type, 22 | "https://api.w.org/meta" => :meta, 23 | "https://api.w.org/featuredmedia" => :post, 24 | "wp:term" => :term, 25 | "wp:items" => :terms, 26 | "wp:post_type" => :post_type, 27 | "wp:meta" => :meta, 28 | "wp:featuredmedia" => :post, 29 | "author" => :user 30 | } 31 | end 32 | 33 | def term(r) 34 | relations = {} 35 | r.resource["_links"][r.relation].each_with_index do |link, position| 36 | relations.merge! Hash[link["taxonomy"], r.load_relation(r.relation, position)] 37 | end 38 | relations 39 | end 40 | 41 | def terms(r) 42 | r.load_relation(r.relation, 0) 43 | end 44 | 45 | def user(r) 46 | r.load_relation(r.relation).first 47 | end 48 | 49 | def post_type(r) 50 | relations = {} 51 | r.resource["_links"][r.relation].each_with_index do |link, position| 52 | # get the post type out of the linked URL. 53 | post_type = URI.parse(link["href"]).path.split('wp/v2/').pop.split('/').first 54 | relations.merge! Hash[post_type, r.load_relation(r.relation, position)] 55 | end 56 | relations 57 | end 58 | 59 | def post(r) 60 | r.load_relation(r.relation) 61 | end 62 | 63 | def meta(r) 64 | relations = {} 65 | meta = WpApiClient.get_client.get(r.resource["_links"][r.relation].first["href"]) 66 | meta.map do |m| 67 | relations.merge! Hash[m.key, m.value] 68 | end 69 | relations 70 | end 71 | end 72 | 73 | attr_reader :resource 74 | attr_reader :relation 75 | 76 | def initialize(resource, relation) 77 | if resource["_links"].keys.include? 'curies' 78 | relation = convert_uri_to_curie(relation) 79 | end 80 | @resource = resource 81 | @relation = relation 82 | end 83 | 84 | def get_relations 85 | mapping = self.class.mappings[@relation] 86 | if !mapping 87 | raise WpApiClient::RelationNotDefined.new %{ 88 | => The relation "#{@relation}" is not defined. 89 | 90 | To add a new relation, define it at configuration. For example, to define this 91 | relation as one that links to a post object, you would do the following. 92 | 93 | WpApiClient.configure do |c| 94 | c.define_mapping(#{@relation}, :post) 95 | end 96 | 97 | The currently defined relations are: 98 | 99 | #{self.class.mappings.keys.join("\n") } 100 | 101 | Available mappings are :post, :term, and :meta.} 102 | end 103 | 104 | # Only try to fetch the relation if there are any links to it 105 | self.class.send(mapping, self) if resource["_links"][relation] 106 | end 107 | 108 | # try to load an embedded object; call out to the API if not 109 | def load_relation(relationship, position = nil) 110 | if objects = @resource.dig("_embedded", relationship) 111 | location = position ? objects[position] : objects 112 | begin 113 | WpApiClient::Collection.new(location) 114 | rescue WpApiClient::ErrorResponse 115 | load_from_links(relationship, position) 116 | end 117 | else 118 | load_from_links(relationship, position) 119 | end 120 | end 121 | 122 | def load_from_links(relationship, position = nil) 123 | unless position.nil? 124 | location = @resource["_links"].dig(relationship, position.to_i, "href") 125 | else 126 | if @resource["_links"][relationship].is_a? Array 127 | # If the resources are linked severally, crank through and 128 | # retrieve them one by one as an array 129 | return @resource["_links"][relationship].map { |link| WpApiClient.get_client.get(link["href"]) } 130 | else 131 | # Otherwise, get the single link to the lot 132 | location = @resource["_links"][relationship]["href"] 133 | end 134 | end 135 | WpApiClient.get_client.get(location) if location 136 | end 137 | 138 | def convert_uri_to_curie(uri) 139 | uri_curie_mappings = { 140 | "https://api.w.org/term" => "wp:term", 141 | "https://api.w.org/items" => "wp:items", 142 | "https://api.w.org/meta" => "wp:meta", 143 | "https://api.w.org/featuredmedia" => "wp:featuredmedia", 144 | "http://api.w.org/v2/post_type" => "wp:post_type" 145 | } 146 | uri_curie_mappings.dig(uri) || uri 147 | end 148 | end 149 | end 150 | -------------------------------------------------------------------------------- /lib/wp_api_client/version.rb: -------------------------------------------------------------------------------- 1 | module WpApiClient 2 | VERSION = "0.3.0" 3 | end 4 | -------------------------------------------------------------------------------- /spec/cassettes/4.4/oauth_test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/posts/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="29ae47991edf5e8b52655f1266f3d529", 14 | oauth_signature="p%2FXIMqjj7%2FX%2B%2BTywNs0H9M3gNdE%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1461005209", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | response: 17 | status: 18 | code: 200 19 | message: OK 20 | headers: 21 | Host: 22 | - localhost:8080 23 | Connection: 24 | - close 25 | X-Powered-By: 26 | - PHP/5.6.9 27 | Content-Type: 28 | - application/json; charset=UTF-8 29 | X-Content-Type-Options: 30 | - nosniff 31 | Access-Control-Expose-Headers: 32 | - X-WP-Total, X-WP-TotalPages 33 | Access-Control-Allow-Headers: 34 | - Authorization 35 | Expires: 36 | - Wed, 11 Jan 1984 05:00:00 GMT 37 | Cache-Control: 38 | - no-cache, must-revalidate, max-age=0 39 | Pragma: 40 | - no-cache 41 | Last-Modified: 42 | - '' 43 | Link: 44 | - ; rel="alternate"; type=text/html 45 | Allow: 46 | - GET, POST, PUT, PATCH, DELETE 47 | body: 48 | encoding: UTF-8 49 | string: '{"id":1,"date":"2016-03-30T00:20:00","date_gmt":"2016-03-30T00:20:00","guid":{"rendered":"http:\/\/localhost:8080\/?p=1"},"modified":"2016-03-30T00:20:00","modified_gmt":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 50 | world!"},"content":{"rendered":"

Welcome to WordPress. This is your first 51 | post. Edit or delete it, then start writing!<\/p>\n"},"excerpt":{"rendered":"

Welcome 52 | to WordPress. This is your first post. Edit or delete it, then start writing!<\/p>\n"},"author":1,"featured_media":203,"comment_status":"open","ping_status":"open","sticky":false,"format":"standard","categories":[1],"tags":[],"custom_taxonomy":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"https:\/\/api.w.org\/featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"https:\/\/api.w.org\/attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"https:\/\/api.w.org\/term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"https:\/\/api.w.org\/meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}]},"_embedded":{"author":[{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}],"replies":[[{"id":1,"parent":0,"author":0,"author_name":"Mr 53 | WordPress","author_url":"https:\/\/wordpress.org\/","author_avatar_urls":{"24":"http:\/\/1.gravatar.com\/avatar\/?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/?s=48&d=mm&r=g","96":"http:\/\/1.gravatar.com\/avatar\/?s=96&d=mm&r=g"},"date":"2016-03-30T00:20:00","content":{"rendered":"

Hi, 54 | this is a comment.
\nTo delete a comment, just log in and view the post's 55 | comments. There you will have the option to edit or delete them.<\/p>\n"},"link":"http:\/\/localhost:8080\/%post%\/#comment-1","type":"comment","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments"}],"up":[{"embeddable":true,"post_type":"post","href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]}}]],"https:\/\/api.w.org\/featuredmedia":[{"id":203,"date":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"alt_text":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}],"https:\/\/api.w.org\/term":[[{"id":1,"link":"http:\/\/localhost:8080\/category\/uncategorized\/","name":"Uncategorized","slug":"uncategorized","taxonomy":"category","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/category"}],"http:\/\/api.w.org\/v2\/post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?categories=1"}]}}],[],[]],"https:\/\/api.w.org\/meta":[{"code":"rest_invalid_param","message":"Invalid 56 | parameter(s): context (context is not one of edit)","data":{"status":400,"params":["context 57 | (context is not one of edit)"]}}]}}' 58 | http_version: 59 | recorded_at: Mon, 18 Apr 2016 18:46:49 GMT 60 | recorded_with: VCR 3.0.1 61 | -------------------------------------------------------------------------------- /spec/cassettes/4.4/single_image.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/media/203?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | response: 13 | status: 14 | code: 200 15 | message: OK 16 | headers: 17 | Host: 18 | - localhost:8080 19 | Connection: 20 | - close 21 | X-Powered-By: 22 | - PHP/5.6.9 23 | Content-Type: 24 | - application/json; charset=UTF-8 25 | X-Content-Type-Options: 26 | - nosniff 27 | Access-Control-Expose-Headers: 28 | - X-WP-Total, X-WP-TotalPages 29 | Access-Control-Allow-Headers: 30 | - Authorization 31 | Link: 32 | - ; rel="alternate"; type=text/html 33 | Allow: 34 | - GET 35 | body: 36 | encoding: UTF-8 37 | string: '{"id":203,"date":"2016-03-30T00:20:04","date_gmt":"2016-03-30T00:20:04","guid":{"rendered":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"},"modified":"2016-03-30T00:20:04","modified_gmt":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"comment_status":"open","ping_status":"closed","alt_text":"","caption":"","description":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"post":null,"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}' 38 | http_version: 39 | recorded_at: Mon, 18 Apr 2016 18:46:46 GMT 40 | recorded_with: VCR 3.0.1 41 | -------------------------------------------------------------------------------- /spec/cassettes/4.4/single_post_auth.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/posts/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="2abd273ce426c4a3bd36f0b39a0d96ab", 14 | oauth_signature="W%2BXSX%2BRZxvllCpZmuPo7T%2F0aJr0%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1461005206", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | response: 17 | status: 18 | code: 200 19 | message: OK 20 | headers: 21 | Host: 22 | - localhost:8080 23 | Connection: 24 | - close 25 | X-Powered-By: 26 | - PHP/5.6.9 27 | Content-Type: 28 | - application/json; charset=UTF-8 29 | X-Content-Type-Options: 30 | - nosniff 31 | Access-Control-Expose-Headers: 32 | - X-WP-Total, X-WP-TotalPages 33 | Access-Control-Allow-Headers: 34 | - Authorization 35 | Expires: 36 | - Wed, 11 Jan 1984 05:00:00 GMT 37 | Cache-Control: 38 | - no-cache, must-revalidate, max-age=0 39 | Pragma: 40 | - no-cache 41 | Last-Modified: 42 | - '' 43 | Link: 44 | - ; rel="alternate"; type=text/html 45 | Allow: 46 | - GET, POST, PUT, PATCH, DELETE 47 | body: 48 | encoding: UTF-8 49 | string: '{"id":1,"date":"2016-03-30T00:20:00","date_gmt":"2016-03-30T00:20:00","guid":{"rendered":"http:\/\/localhost:8080\/?p=1"},"modified":"2016-03-30T00:20:00","modified_gmt":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 50 | world!"},"content":{"rendered":"

Welcome to WordPress. This is your first 51 | post. Edit or delete it, then start writing!<\/p>\n"},"excerpt":{"rendered":"

Welcome 52 | to WordPress. This is your first post. Edit or delete it, then start writing!<\/p>\n"},"author":1,"featured_media":203,"comment_status":"open","ping_status":"open","sticky":false,"format":"standard","categories":[1],"tags":[],"custom_taxonomy":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"https:\/\/api.w.org\/featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"https:\/\/api.w.org\/attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"https:\/\/api.w.org\/term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"https:\/\/api.w.org\/meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}]},"_embedded":{"author":[{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}],"replies":[[{"id":1,"parent":0,"author":0,"author_name":"Mr 53 | WordPress","author_url":"https:\/\/wordpress.org\/","author_avatar_urls":{"24":"http:\/\/1.gravatar.com\/avatar\/?s=24&d=mm&r=g","48":"http:\/\/2.gravatar.com\/avatar\/?s=48&d=mm&r=g","96":"http:\/\/1.gravatar.com\/avatar\/?s=96&d=mm&r=g"},"date":"2016-03-30T00:20:00","content":{"rendered":"

Hi, 54 | this is a comment.
\nTo delete a comment, just log in and view the post's 55 | comments. There you will have the option to edit or delete them.<\/p>\n"},"link":"http:\/\/localhost:8080\/%post%\/#comment-1","type":"comment","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments"}],"up":[{"embeddable":true,"post_type":"post","href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]}}]],"https:\/\/api.w.org\/featuredmedia":[{"id":203,"date":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"alt_text":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}],"https:\/\/api.w.org\/term":[[{"id":1,"link":"http:\/\/localhost:8080\/category\/uncategorized\/","name":"Uncategorized","slug":"uncategorized","taxonomy":"category","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/category"}],"http:\/\/api.w.org\/v2\/post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?categories=1"}]}}],[],[]],"https:\/\/api.w.org\/meta":[{"code":"rest_invalid_param","message":"Invalid 56 | parameter(s): context (context is not one of edit)","data":{"status":400,"params":["context 57 | (context is not one of edit)"]}}]}}' 58 | http_version: 59 | recorded_at: Mon, 18 Apr 2016 18:46:46 GMT 60 | - request: 61 | method: get 62 | uri: http://localhost:8080/wp-json/wp/v2/posts/1/meta?_embed=true 63 | body: 64 | encoding: US-ASCII 65 | string: '' 66 | headers: 67 | User-Agent: 68 | - Faraday v0.9.2 69 | Authorization: 70 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="a1741a03bdd2bac313953a77f3beac51", 71 | oauth_signature="YpTCczLy9FBndwrw3MmRUCtycQ4%3D", oauth_signature_method="HMAC-SHA1", 72 | oauth_timestamp="1461005206", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 73 | response: 74 | status: 75 | code: 200 76 | message: OK 77 | headers: 78 | Host: 79 | - localhost:8080 80 | Connection: 81 | - close 82 | X-Powered-By: 83 | - PHP/5.6.9 84 | Content-Type: 85 | - application/json; charset=UTF-8 86 | X-Content-Type-Options: 87 | - nosniff 88 | Access-Control-Expose-Headers: 89 | - X-WP-Total, X-WP-TotalPages 90 | Access-Control-Allow-Headers: 91 | - Authorization 92 | Expires: 93 | - Wed, 11 Jan 1984 05:00:00 GMT 94 | Cache-Control: 95 | - no-cache, must-revalidate, max-age=0 96 | Pragma: 97 | - no-cache 98 | Last-Modified: 99 | - '' 100 | Allow: 101 | - GET, POST 102 | body: 103 | encoding: UTF-8 104 | string: '[{"id":205,"key":"example_metadata_field","value":"example_meta_value","_links":{"about":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]},"_embedded":{"about":[{"id":1,"date":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 105 | world!"},"excerpt":{"rendered":"

Welcome to WordPress. This is your first 106 | post. Edit or delete it, then start writing!<\/p>\n"},"author":1,"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"https:\/\/api.w.org\/featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"https:\/\/api.w.org\/attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"https:\/\/api.w.org\/term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"https:\/\/api.w.org\/meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}]}}]}},{"id":206,"key":"example_associated_post_id","value":"100","_links":{"about":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]},"_embedded":{"about":[{"id":1,"date":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 107 | world!"},"excerpt":{"rendered":"

Welcome to WordPress. This is your first 108 | post. Edit or delete it, then start writing!<\/p>\n"},"author":1,"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"https:\/\/api.w.org\/featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"https:\/\/api.w.org\/attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"https:\/\/api.w.org\/term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"https:\/\/api.w.org\/meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}]}}]}}]' 109 | http_version: 110 | recorded_at: Mon, 18 Apr 2016 18:46:46 GMT 111 | recorded_with: VCR 3.0.1 112 | -------------------------------------------------------------------------------- /spec/cassettes/4.4/single_taxonomy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/taxonomies/custom_taxonomy?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="e28e8517d05a6877677474aa0776bbd8", 14 | oauth_signature="QiaDidqXtLW5L3YStMrTt8ij%2FM4%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1461005207", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | response: 17 | status: 18 | code: 200 19 | message: OK 20 | headers: 21 | Host: 22 | - localhost:8080 23 | Connection: 24 | - close 25 | X-Powered-By: 26 | - PHP/5.6.9 27 | Content-Type: 28 | - application/json; charset=UTF-8 29 | X-Content-Type-Options: 30 | - nosniff 31 | Access-Control-Expose-Headers: 32 | - X-WP-Total, X-WP-TotalPages 33 | Access-Control-Allow-Headers: 34 | - Authorization 35 | Expires: 36 | - Wed, 11 Jan 1984 05:00:00 GMT 37 | Cache-Control: 38 | - no-cache, must-revalidate, max-age=0 39 | Pragma: 40 | - no-cache 41 | Last-Modified: 42 | - '' 43 | Allow: 44 | - GET 45 | body: 46 | encoding: UTF-8 47 | string: '{"name":"Custom taxonomy","slug":"custom_taxonomy","description":"","types":["custom_post_type","post"],"hierarchical":false,"_links":{"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies"}],"https:\/\/api.w.org\/items":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}]}}' 48 | http_version: 49 | recorded_at: Mon, 18 Apr 2016 18:46:47 GMT 50 | - request: 51 | method: get 52 | uri: http://localhost:8080/wp-json/wp/v2/custom_taxonomy?_embed=true 53 | body: 54 | encoding: US-ASCII 55 | string: '' 56 | headers: 57 | User-Agent: 58 | - Faraday v0.9.2 59 | Authorization: 60 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="dbad389037857aa24f92c3b251b051ea", 61 | oauth_signature="1HeZi1wdX6u8A3sGRn4IvzB60DQ%3D", oauth_signature_method="HMAC-SHA1", 62 | oauth_timestamp="1461005207", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 63 | response: 64 | status: 65 | code: 200 66 | message: OK 67 | headers: 68 | Host: 69 | - localhost:8080 70 | Connection: 71 | - close 72 | X-Powered-By: 73 | - PHP/5.6.9 74 | Content-Type: 75 | - application/json; charset=UTF-8 76 | X-Content-Type-Options: 77 | - nosniff 78 | Access-Control-Expose-Headers: 79 | - X-WP-Total, X-WP-TotalPages 80 | Access-Control-Allow-Headers: 81 | - Authorization 82 | Expires: 83 | - Wed, 11 Jan 1984 05:00:00 GMT 84 | Cache-Control: 85 | - no-cache, must-revalidate, max-age=0 86 | Pragma: 87 | - no-cache 88 | Last-Modified: 89 | - '' 90 | X-Wp-Total: 91 | - '2' 92 | X-Wp-Totalpages: 93 | - '1' 94 | Allow: 95 | - GET, POST 96 | body: 97 | encoding: UTF-8 98 | string: '[{"id":2,"count":20,"description":"","link":"http:\/\/localhost:8080\/custom_taxonomy\/term_one\/","name":"term_one","slug":"term_one","taxonomy":"custom_taxonomy","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy\/2"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/custom_taxonomy"}],"http:\/\/api.w.org\/v2\/post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_post_type?custom_taxonomy=2"},{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?custom_taxonomy=2"}]}},{"id":3,"count":10,"description":"","link":"http:\/\/localhost:8080\/custom_taxonomy\/term_two\/","name":"term_two","slug":"term_two","taxonomy":"custom_taxonomy","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy\/3"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/custom_taxonomy"}],"http:\/\/api.w.org\/v2\/post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_post_type?custom_taxonomy=3"},{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?custom_taxonomy=3"}]}}]' 99 | http_version: 100 | recorded_at: Mon, 18 Apr 2016 18:46:48 GMT 101 | recorded_with: VCR 3.0.1 102 | -------------------------------------------------------------------------------- /spec/cassettes/4.4/single_user.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/users/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="b6b95b3485f41959e0081278c57abad9", 14 | oauth_signature="T0UF83iryK11rr6zbiUp57Gs2rQ%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1469635935", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.21 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Content-Type-Options: 32 | - nosniff 33 | Access-Control-Expose-Headers: 34 | - X-WP-Total, X-WP-TotalPages 35 | Access-Control-Allow-Headers: 36 | - Authorization 37 | Expires: 38 | - Wed, 11 Jan 1984 05:00:00 GMT 39 | Cache-Control: 40 | - no-cache, must-revalidate, max-age=0 41 | Pragma: 42 | - no-cache 43 | Last-Modified: 44 | - '' 45 | Allow: 46 | - GET, POST, PUT, PATCH, DELETE 47 | body: 48 | encoding: UTF-8 49 | string: '{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}' 50 | http_version: 51 | recorded_at: Wed, 27 Jul 2016 16:12:15 GMT 52 | recorded_with: VCR 3.0.3 53 | -------------------------------------------------------------------------------- /spec/cassettes/4.5.3/oauth_test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/posts/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="83ce83897fb8d72b6a1667645444e058", 14 | oauth_signature="SMPxHPoXg0sDYW9KBHWrqQIlQcw%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1469192205", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.21 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Content-Type-Options: 32 | - nosniff 33 | Access-Control-Expose-Headers: 34 | - X-WP-Total, X-WP-TotalPages 35 | Access-Control-Allow-Headers: 36 | - Authorization 37 | Expires: 38 | - Wed, 11 Jan 1984 05:00:00 GMT 39 | Cache-Control: 40 | - no-cache, must-revalidate, max-age=0 41 | Pragma: 42 | - no-cache 43 | Last-Modified: 44 | - '' 45 | Link: 46 | - ; rel="alternate"; type=text/html 47 | Allow: 48 | - GET, POST, PUT, PATCH, DELETE 49 | body: 50 | encoding: UTF-8 51 | string: '{"id":1,"date":"2016-03-30T00:20:00","date_gmt":"2016-03-30T00:20:00","guid":{"rendered":"http:\/\/localhost:8080\/?p=1"},"modified":"2016-03-30T00:20:00","modified_gmt":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 52 | world!"},"content":{"rendered":"

Welcome to WordPress. This is your first 53 | post. Edit or delete it, then start writing!<\/p>\n"},"excerpt":{"rendered":"

Welcome 54 | to WordPress. This is your first post. Edit or delete it, then start writing!<\/p>\n"},"author":1,"featured_media":203,"comment_status":"open","ping_status":"open","sticky":false,"format":"standard","categories":[1],"tags":[],"custom_taxonomy":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]},"_embedded":{"author":[{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}],"replies":[[{"id":1,"parent":0,"author":0,"author_name":"Mr 55 | WordPress","author_url":"https:\/\/wordpress.org\/","author_avatar_urls":{"24":"http:\/\/1.gravatar.com\/avatar\/?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/?s=48&d=mm&r=g","96":"http:\/\/2.gravatar.com\/avatar\/?s=96&d=mm&r=g"},"date":"2016-03-30T00:20:00","content":{"rendered":"

Hi, 56 | this is a comment.
\nTo delete a comment, just log in and view the post's 57 | comments. There you will have the option to edit or delete them.<\/p>\n"},"link":"http:\/\/localhost:8080\/%post%\/#comment-1","type":"comment","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments"}],"up":[{"embeddable":true,"post_type":"post","href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]}}]],"wp:featuredmedia":[{"id":203,"date":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"alt_text":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}],"wp:term":[[{"id":1,"link":"http:\/\/localhost:8080\/category\/uncategorized\/","name":"Uncategorized","slug":"uncategorized","taxonomy":"category","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/category"}],"http:\/\/api.w.org\/v2\/post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?categories=1"}]}}],[],[]],"wp:meta":[{"code":"rest_invalid_param","message":"Invalid 58 | parameter(s): context","data":{"status":400,"params":{"context":"context is 59 | not one of edit"}}}]}}' 60 | http_version: 61 | recorded_at: Fri, 22 Jul 2016 12:56:46 GMT 62 | recorded_with: VCR 3.0.3 63 | -------------------------------------------------------------------------------- /spec/cassettes/4.5.3/single_image.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/media/203?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Expect: 13 | - '' 14 | response: 15 | status: 16 | code: 200 17 | message: OK 18 | headers: 19 | Host: 20 | - localhost:8080 21 | Connection: 22 | - close 23 | X-Powered-By: 24 | - PHP/5.6.21 25 | Content-Type: 26 | - application/json; charset=UTF-8 27 | X-Content-Type-Options: 28 | - nosniff 29 | Access-Control-Expose-Headers: 30 | - X-WP-Total, X-WP-TotalPages 31 | Access-Control-Allow-Headers: 32 | - Authorization 33 | Link: 34 | - ; rel="alternate"; type=text/html 35 | Allow: 36 | - GET 37 | body: 38 | encoding: UTF-8 39 | string: '{"id":203,"date":"2016-03-30T00:20:04","date_gmt":"2016-03-30T00:20:04","guid":{"rendered":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"},"modified":"2016-03-30T00:20:04","modified_gmt":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"comment_status":"open","ping_status":"closed","alt_text":"","caption":"","description":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"post":null,"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}' 40 | http_version: 41 | recorded_at: Fri, 22 Jul 2016 12:56:42 GMT 42 | recorded_with: VCR 3.0.3 43 | -------------------------------------------------------------------------------- /spec/cassettes/4.5.3/single_post_auth.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/posts/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="8f863e5420348dc3ee864aff5476eb1b", 14 | oauth_signature="ijZE1ldC%2F5xN9%2FylkVdctj2EpG0%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1469192202", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.21 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Content-Type-Options: 32 | - nosniff 33 | Access-Control-Expose-Headers: 34 | - X-WP-Total, X-WP-TotalPages 35 | Access-Control-Allow-Headers: 36 | - Authorization 37 | Expires: 38 | - Wed, 11 Jan 1984 05:00:00 GMT 39 | Cache-Control: 40 | - no-cache, must-revalidate, max-age=0 41 | Pragma: 42 | - no-cache 43 | Last-Modified: 44 | - '' 45 | Link: 46 | - ; rel="alternate"; type=text/html 47 | Allow: 48 | - GET, POST, PUT, PATCH, DELETE 49 | body: 50 | encoding: UTF-8 51 | string: '{"id":1,"date":"2016-03-30T00:20:00","date_gmt":"2016-03-30T00:20:00","guid":{"rendered":"http:\/\/localhost:8080\/?p=1"},"modified":"2016-03-30T00:20:00","modified_gmt":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 52 | world!"},"content":{"rendered":"

Welcome to WordPress. This is your first 53 | post. Edit or delete it, then start writing!<\/p>\n"},"excerpt":{"rendered":"

Welcome 54 | to WordPress. This is your first post. Edit or delete it, then start writing!<\/p>\n"},"author":1,"featured_media":203,"comment_status":"open","ping_status":"open","sticky":false,"format":"standard","categories":[1],"tags":[],"custom_taxonomy":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]},"_embedded":{"author":[{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}],"replies":[[{"id":1,"parent":0,"author":0,"author_name":"Mr 55 | WordPress","author_url":"https:\/\/wordpress.org\/","author_avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/?s=48&d=mm&r=g","96":"http:\/\/2.gravatar.com\/avatar\/?s=96&d=mm&r=g"},"date":"2016-03-30T00:20:00","content":{"rendered":"

Hi, 56 | this is a comment.
\nTo delete a comment, just log in and view the post's 57 | comments. There you will have the option to edit or delete them.<\/p>\n"},"link":"http:\/\/localhost:8080\/%post%\/#comment-1","type":"comment","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments"}],"up":[{"embeddable":true,"post_type":"post","href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]}}]],"wp:featuredmedia":[{"id":203,"date":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"alt_text":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}],"wp:term":[[{"id":1,"link":"http:\/\/localhost:8080\/category\/uncategorized\/","name":"Uncategorized","slug":"uncategorized","taxonomy":"category","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/category"}],"http:\/\/api.w.org\/v2\/post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?categories=1"}]}}],[],[]],"wp:meta":[{"code":"rest_invalid_param","message":"Invalid 58 | parameter(s): context","data":{"status":400,"params":{"context":"context is 59 | not one of edit"}}}]}}' 60 | http_version: 61 | recorded_at: Fri, 22 Jul 2016 12:56:42 GMT 62 | - request: 63 | method: get 64 | uri: http://localhost:8080/wp-json/wp/v2/posts/1/meta?_embed=true 65 | body: 66 | encoding: US-ASCII 67 | string: '' 68 | headers: 69 | User-Agent: 70 | - Faraday v0.9.2 71 | Authorization: 72 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="6e88e2c1ba5273baa1a3dd65ebb3905c", 73 | oauth_signature="5%2FBN2Vk4%2F%2BlUvecrFjMH1d4kfFU%3D", oauth_signature_method="HMAC-SHA1", 74 | oauth_timestamp="1469192202", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 75 | Expect: 76 | - '' 77 | response: 78 | status: 79 | code: 200 80 | message: OK 81 | headers: 82 | Host: 83 | - localhost:8080 84 | Connection: 85 | - close 86 | X-Powered-By: 87 | - PHP/5.6.21 88 | Content-Type: 89 | - application/json; charset=UTF-8 90 | X-Content-Type-Options: 91 | - nosniff 92 | Access-Control-Expose-Headers: 93 | - X-WP-Total, X-WP-TotalPages 94 | Access-Control-Allow-Headers: 95 | - Authorization 96 | Expires: 97 | - Wed, 11 Jan 1984 05:00:00 GMT 98 | Cache-Control: 99 | - no-cache, must-revalidate, max-age=0 100 | Pragma: 101 | - no-cache 102 | Last-Modified: 103 | - '' 104 | Allow: 105 | - GET, POST 106 | body: 107 | encoding: UTF-8 108 | string: '[{"id":205,"key":"example_metadata_field","value":"example_meta_value","_links":{"about":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]},"_embedded":{"about":[{"id":1,"date":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 109 | world!"},"excerpt":{"rendered":"

Welcome to WordPress. This is your first 110 | post. Edit or delete it, then start writing!<\/p>\n"},"author":1,"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]}},{"id":206,"key":"example_associated_post_id","value":"100","_links":{"about":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]},"_embedded":{"about":[{"id":1,"date":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 111 | world!"},"excerpt":{"rendered":"

Welcome to WordPress. This is your first 112 | post. Edit or delete it, then start writing!<\/p>\n"},"author":1,"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]}}]' 113 | http_version: 114 | recorded_at: Fri, 22 Jul 2016 12:56:42 GMT 115 | recorded_with: VCR 3.0.3 116 | -------------------------------------------------------------------------------- /spec/cassettes/4.5.3/single_taxonomy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/taxonomies/custom_taxonomy?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="5164963c4edd51b7918575535528583c", 14 | oauth_signature="rfJUrxoh9kHfkRb%2F59pnglDRTUc%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1469192203", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.21 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Content-Type-Options: 32 | - nosniff 33 | Access-Control-Expose-Headers: 34 | - X-WP-Total, X-WP-TotalPages 35 | Access-Control-Allow-Headers: 36 | - Authorization 37 | Expires: 38 | - Wed, 11 Jan 1984 05:00:00 GMT 39 | Cache-Control: 40 | - no-cache, must-revalidate, max-age=0 41 | Pragma: 42 | - no-cache 43 | Last-Modified: 44 | - '' 45 | Allow: 46 | - GET 47 | body: 48 | encoding: UTF-8 49 | string: '{"name":"Custom taxonomy","slug":"custom_taxonomy","description":"","types":["custom_post_type","post"],"hierarchical":false,"_links":{"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies"}],"wp:items":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}' 50 | http_version: 51 | recorded_at: Fri, 22 Jul 2016 12:56:44 GMT 52 | - request: 53 | method: get 54 | uri: http://localhost:8080/wp-json/wp/v2/custom_taxonomy?_embed=true 55 | body: 56 | encoding: US-ASCII 57 | string: '' 58 | headers: 59 | User-Agent: 60 | - Faraday v0.9.2 61 | Authorization: 62 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="43a53ed1aa96e924c5f413cb2376b34a", 63 | oauth_signature="Ct%2BnWzcMpg%2Fau8RF3C%2BmmiDhNRU%3D", oauth_signature_method="HMAC-SHA1", 64 | oauth_timestamp="1469192204", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 65 | Expect: 66 | - '' 67 | response: 68 | status: 69 | code: 200 70 | message: OK 71 | headers: 72 | Host: 73 | - localhost:8080 74 | Connection: 75 | - close 76 | X-Powered-By: 77 | - PHP/5.6.21 78 | Content-Type: 79 | - application/json; charset=UTF-8 80 | X-Content-Type-Options: 81 | - nosniff 82 | Access-Control-Expose-Headers: 83 | - X-WP-Total, X-WP-TotalPages 84 | Access-Control-Allow-Headers: 85 | - Authorization 86 | Expires: 87 | - Wed, 11 Jan 1984 05:00:00 GMT 88 | Cache-Control: 89 | - no-cache, must-revalidate, max-age=0 90 | Pragma: 91 | - no-cache 92 | Last-Modified: 93 | - '' 94 | X-Wp-Total: 95 | - '2' 96 | X-Wp-Totalpages: 97 | - '1' 98 | Allow: 99 | - GET, POST 100 | body: 101 | encoding: UTF-8 102 | string: '[{"id":2,"count":20,"description":"","link":"http:\/\/localhost:8080\/custom_taxonomy\/term_one\/","name":"term_one","slug":"term_one","taxonomy":"custom_taxonomy","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy\/2"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/custom_taxonomy"}],"http:\/\/api.w.org\/v2\/post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_post_type?custom_taxonomy=2"},{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?custom_taxonomy=2"}]}},{"id":3,"count":10,"description":"","link":"http:\/\/localhost:8080\/custom_taxonomy\/term_two\/","name":"term_two","slug":"term_two","taxonomy":"custom_taxonomy","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy\/3"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/custom_taxonomy"}],"http:\/\/api.w.org\/v2\/post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_post_type?custom_taxonomy=3"},{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?custom_taxonomy=3"}]}}]' 103 | http_version: 104 | recorded_at: Fri, 22 Jul 2016 12:56:44 GMT 105 | recorded_with: VCR 3.0.3 106 | -------------------------------------------------------------------------------- /spec/cassettes/4.5.3/single_user.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/users/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="60fe678ed7af694d9c5b22ea7b6196e4", 14 | oauth_signature="Ar6WDg8x7UgcwM4m57N5ZkMTlNE%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1469636148", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.21 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Content-Type-Options: 32 | - nosniff 33 | Access-Control-Expose-Headers: 34 | - X-WP-Total, X-WP-TotalPages 35 | Access-Control-Allow-Headers: 36 | - Authorization 37 | Expires: 38 | - Wed, 11 Jan 1984 05:00:00 GMT 39 | Cache-Control: 40 | - no-cache, must-revalidate, max-age=0 41 | Pragma: 42 | - no-cache 43 | Last-Modified: 44 | - '' 45 | Allow: 46 | - GET, POST, PUT, PATCH, DELETE 47 | body: 48 | encoding: UTF-8 49 | string: '{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}' 50 | http_version: 51 | recorded_at: Wed, 27 Jul 2016 16:15:48 GMT 52 | recorded_with: VCR 3.0.3 53 | -------------------------------------------------------------------------------- /spec/cassettes/4.5.3_b13/oauth_test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/posts/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="5d39b4fce026cc708a5b695495d603da", 14 | oauth_signature="2RY1Af%2BpCpVMUMviip7IXt0emHE%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1469636256", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.21 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Content-Type-Options: 32 | - nosniff 33 | Access-Control-Expose-Headers: 34 | - X-WP-Total, X-WP-TotalPages 35 | Access-Control-Allow-Headers: 36 | - Authorization 37 | Expires: 38 | - Wed, 11 Jan 1984 05:00:00 GMT 39 | Cache-Control: 40 | - no-cache, must-revalidate, max-age=0 41 | Pragma: 42 | - no-cache 43 | Last-Modified: 44 | - '' 45 | Link: 46 | - ; rel="alternate"; type=text/html 47 | Allow: 48 | - GET, POST, PUT, PATCH, DELETE 49 | body: 50 | encoding: UTF-8 51 | string: '{"id":1,"date":"2016-03-30T00:20:00","date_gmt":"2016-03-30T00:20:00","guid":{"rendered":"http:\/\/localhost:8080\/?p=1"},"modified":"2016-03-30T00:20:00","modified_gmt":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 52 | world!"},"content":{"rendered":"

Welcome to WordPress. This is your first 53 | post. Edit or delete it, then start writing!<\/p>\n"},"excerpt":{"rendered":"

Welcome 54 | to WordPress. This is your first post. Edit or delete it, then start writing!<\/p>\n"},"author":1,"featured_media":203,"comment_status":"open","ping_status":"open","sticky":false,"format":"standard","categories":[1],"tags":[],"custom_taxonomy":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"},{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]},"_embedded":{"author":[{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}],"replies":[[{"id":1,"parent":0,"author":0,"author_name":"Mr 55 | WordPress","author_url":"https:\/\/wordpress.org\/","author_avatar_urls":{"24":"http:\/\/1.gravatar.com\/avatar\/?s=24&d=mm&r=g","48":"http:\/\/1.gravatar.com\/avatar\/?s=48&d=mm&r=g","96":"http:\/\/1.gravatar.com\/avatar\/?s=96&d=mm&r=g"},"date":"2016-03-30T00:20:00","content":{"rendered":"

Hi, 56 | this is a comment.
\nTo delete a comment, just log in and view the post's 57 | comments. There you will have the option to edit or delete them.<\/p>\n"},"link":"http:\/\/localhost:8080\/%post%\/#comment-1","type":"comment","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments"}],"up":[{"embeddable":true,"post_type":"post","href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]}}]],"wp:featuredmedia":[{"id":203,"date":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"alt_text":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}],"wp:term":[[{"id":1,"link":"http:\/\/localhost:8080\/category\/uncategorized\/","name":"Uncategorized","slug":"uncategorized","taxonomy":"category","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/category"}],"http:\/\/api.w.org\/v2\/post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?categories=1"}]}}],[],[]],"wp:meta":[{"code":"rest_invalid_param","message":"Invalid 58 | parameter(s): context","data":{"status":400,"params":{"context":"context is 59 | not one of edit"}}},{"code":"rest_invalid_param","message":"Invalid parameter(s): 60 | context","data":{"status":400,"params":{"context":"context is not one of edit"}}}]}}' 61 | http_version: 62 | recorded_at: Wed, 27 Jul 2016 16:17:37 GMT 63 | recorded_with: VCR 3.0.3 64 | -------------------------------------------------------------------------------- /spec/cassettes/4.5.3_b13/single_image.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/media/203?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Expect: 13 | - '' 14 | response: 15 | status: 16 | code: 200 17 | message: OK 18 | headers: 19 | Host: 20 | - localhost:8080 21 | Connection: 22 | - close 23 | X-Powered-By: 24 | - PHP/5.6.21 25 | Content-Type: 26 | - application/json; charset=UTF-8 27 | X-Content-Type-Options: 28 | - nosniff 29 | Access-Control-Expose-Headers: 30 | - X-WP-Total, X-WP-TotalPages 31 | Access-Control-Allow-Headers: 32 | - Authorization 33 | Link: 34 | - ; rel="alternate"; type=text/html 35 | Allow: 36 | - GET 37 | body: 38 | encoding: UTF-8 39 | string: '{"id":203,"date":"2016-03-30T00:20:04","date_gmt":"2016-03-30T00:20:04","guid":{"rendered":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"},"modified":"2016-03-30T00:20:04","modified_gmt":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"comment_status":"open","ping_status":"closed","alt_text":"","caption":"","description":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"post":null,"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}' 40 | http_version: 41 | recorded_at: Wed, 27 Jul 2016 16:17:33 GMT 42 | recorded_with: VCR 3.0.3 43 | -------------------------------------------------------------------------------- /spec/cassettes/4.5.3_b13/single_taxonomy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/taxonomies/custom_taxonomy?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="c5a5ac807911b54417f91fa3f1698dff", 14 | oauth_signature="BkuDrkNMACMmmjqAZfx384vLZbk%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1469636254", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.21 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Content-Type-Options: 32 | - nosniff 33 | Access-Control-Expose-Headers: 34 | - X-WP-Total, X-WP-TotalPages 35 | Access-Control-Allow-Headers: 36 | - Authorization 37 | Expires: 38 | - Wed, 11 Jan 1984 05:00:00 GMT 39 | Cache-Control: 40 | - no-cache, must-revalidate, max-age=0 41 | Pragma: 42 | - no-cache 43 | Last-Modified: 44 | - '' 45 | Allow: 46 | - GET 47 | body: 48 | encoding: UTF-8 49 | string: '{"name":"Custom taxonomy","slug":"custom_taxonomy","description":"","types":["custom_post_type","post"],"hierarchical":false,"_links":{"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies"}],"wp:items":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}' 50 | http_version: 51 | recorded_at: Wed, 27 Jul 2016 16:17:34 GMT 52 | - request: 53 | method: get 54 | uri: http://localhost:8080/wp-json/wp/v2/custom_taxonomy?_embed=true 55 | body: 56 | encoding: US-ASCII 57 | string: '' 58 | headers: 59 | User-Agent: 60 | - Faraday v0.9.2 61 | Authorization: 62 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="0a4bd079d6681b4c36ceda7703c1b9a7", 63 | oauth_signature="5CfdR9H16xmr63ByzdIpYYhfuck%3D", oauth_signature_method="HMAC-SHA1", 64 | oauth_timestamp="1469636254", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 65 | Expect: 66 | - '' 67 | response: 68 | status: 69 | code: 200 70 | message: OK 71 | headers: 72 | Host: 73 | - localhost:8080 74 | Connection: 75 | - close 76 | X-Powered-By: 77 | - PHP/5.6.21 78 | Content-Type: 79 | - application/json; charset=UTF-8 80 | X-Content-Type-Options: 81 | - nosniff 82 | Access-Control-Expose-Headers: 83 | - X-WP-Total, X-WP-TotalPages 84 | Access-Control-Allow-Headers: 85 | - Authorization 86 | Expires: 87 | - Wed, 11 Jan 1984 05:00:00 GMT 88 | Cache-Control: 89 | - no-cache, must-revalidate, max-age=0 90 | Pragma: 91 | - no-cache 92 | Last-Modified: 93 | - '' 94 | X-Wp-Total: 95 | - '2' 96 | X-Wp-Totalpages: 97 | - '1' 98 | Allow: 99 | - GET, POST 100 | body: 101 | encoding: UTF-8 102 | string: '[{"id":2,"count":20,"description":"","link":"http:\/\/localhost:8080\/custom_taxonomy\/term_one\/","name":"term_one","slug":"term_one","taxonomy":"custom_taxonomy","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy\/2"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/custom_taxonomy"}],"http:\/\/api.w.org\/v2\/post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_post_type?custom_taxonomy=2"},{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?custom_taxonomy=2"}]}},{"id":3,"count":10,"description":"","link":"http:\/\/localhost:8080\/custom_taxonomy\/term_two\/","name":"term_two","slug":"term_two","taxonomy":"custom_taxonomy","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy\/3"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/custom_taxonomy"}],"http:\/\/api.w.org\/v2\/post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_post_type?custom_taxonomy=3"},{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?custom_taxonomy=3"}]}}]' 103 | http_version: 104 | recorded_at: Wed, 27 Jul 2016 16:17:34 GMT 105 | recorded_with: VCR 3.0.3 106 | -------------------------------------------------------------------------------- /spec/cassettes/4.5.3_b13/single_user.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/users/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="ea207f69de2a9531c412619d91ba108f", 14 | oauth_signature="2NbJaV71XncYtVr7e7wMROGxaLQ%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1469636256", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.21 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Content-Type-Options: 32 | - nosniff 33 | Access-Control-Expose-Headers: 34 | - X-WP-Total, X-WP-TotalPages 35 | Access-Control-Allow-Headers: 36 | - Authorization 37 | Expires: 38 | - Wed, 11 Jan 1984 05:00:00 GMT 39 | Cache-Control: 40 | - no-cache, must-revalidate, max-age=0 41 | Pragma: 42 | - no-cache 43 | Last-Modified: 44 | - '' 45 | Allow: 46 | - GET, POST, PUT, PATCH, DELETE 47 | body: 48 | encoding: UTF-8 49 | string: '{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}' 50 | http_version: 51 | recorded_at: Wed, 27 Jul 2016 16:17:36 GMT 52 | recorded_with: VCR 3.0.3 53 | -------------------------------------------------------------------------------- /spec/cassettes/4.5/oauth_test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/posts/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="f754e7ad220370746c507770f0c78028", 14 | oauth_signature="7TP7QiWZ0by7P3YHxij%2BSU503a4%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1461005370", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | response: 17 | status: 18 | code: 200 19 | message: OK 20 | headers: 21 | Host: 22 | - localhost:8080 23 | Connection: 24 | - close 25 | X-Powered-By: 26 | - PHP/5.6.9 27 | Content-Type: 28 | - application/json; charset=UTF-8 29 | X-Content-Type-Options: 30 | - nosniff 31 | Access-Control-Expose-Headers: 32 | - X-WP-Total, X-WP-TotalPages 33 | Access-Control-Allow-Headers: 34 | - Authorization 35 | Expires: 36 | - Wed, 11 Jan 1984 05:00:00 GMT 37 | Cache-Control: 38 | - no-cache, must-revalidate, max-age=0 39 | Pragma: 40 | - no-cache 41 | Last-Modified: 42 | - '' 43 | Link: 44 | - ; rel="alternate"; type=text/html 45 | Allow: 46 | - GET, POST, PUT, PATCH, DELETE 47 | body: 48 | encoding: UTF-8 49 | string: '{"id":1,"date":"2016-03-30T00:20:00","date_gmt":"2016-03-30T00:20:00","guid":{"rendered":"http:\/\/localhost:8080\/?p=1"},"modified":"2016-03-30T00:20:00","modified_gmt":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 50 | world!"},"content":{"rendered":"

Welcome to WordPress. This is your first 51 | post. Edit or delete it, then start writing!<\/p>\n"},"excerpt":{"rendered":"

Welcome 52 | to WordPress. This is your first post. Edit or delete it, then start writing!<\/p>\n"},"author":1,"featured_media":203,"comment_status":"open","ping_status":"open","sticky":false,"format":"standard","categories":[1],"tags":[],"custom_taxonomy":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]},"_embedded":{"author":[{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}],"replies":[[{"id":1,"parent":0,"author":0,"author_name":"Mr 53 | WordPress","author_url":"https:\/\/wordpress.org\/","author_avatar_urls":{"24":"http:\/\/1.gravatar.com\/avatar\/?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/?s=96&d=mm&r=g"},"date":"2016-03-30T00:20:00","content":{"rendered":"

Hi, 54 | this is a comment.
\nTo delete a comment, just log in and view the post's 55 | comments. There you will have the option to edit or delete them.<\/p>\n"},"link":"http:\/\/localhost:8080\/%post%\/#comment-1","type":"comment","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments"}],"up":[{"embeddable":true,"post_type":"post","href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]}}]],"wp:featuredmedia":[{"id":203,"date":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"alt_text":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}],"wp:term":[[{"id":1,"link":"http:\/\/localhost:8080\/category\/uncategorized\/","name":"Uncategorized","slug":"uncategorized","taxonomy":"category","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/category"}],"http:\/\/api.w.org\/v2\/post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?categories=1"}]}}],[],[]],"wp:meta":[{"code":"rest_invalid_param","message":"Invalid 56 | parameter(s): context","data":{"status":400,"params":{"context":"context is 57 | not one of edit"}}}]}}' 58 | http_version: 59 | recorded_at: Mon, 18 Apr 2016 18:49:30 GMT 60 | recorded_with: VCR 3.0.1 61 | -------------------------------------------------------------------------------- /spec/cassettes/4.5/single_image.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/media/203?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | response: 13 | status: 14 | code: 200 15 | message: OK 16 | headers: 17 | Host: 18 | - localhost:8080 19 | Connection: 20 | - close 21 | X-Powered-By: 22 | - PHP/5.6.9 23 | Content-Type: 24 | - application/json; charset=UTF-8 25 | X-Content-Type-Options: 26 | - nosniff 27 | Access-Control-Expose-Headers: 28 | - X-WP-Total, X-WP-TotalPages 29 | Access-Control-Allow-Headers: 30 | - Authorization 31 | Link: 32 | - ; rel="alternate"; type=text/html 33 | Allow: 34 | - GET 35 | body: 36 | encoding: UTF-8 37 | string: '{"id":203,"date":"2016-03-30T00:20:04","date_gmt":"2016-03-30T00:20:04","guid":{"rendered":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"},"modified":"2016-03-30T00:20:04","modified_gmt":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"comment_status":"open","ping_status":"closed","alt_text":"","caption":"","description":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"post":null,"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}' 38 | http_version: 39 | recorded_at: Mon, 18 Apr 2016 18:49:28 GMT 40 | recorded_with: VCR 3.0.1 41 | -------------------------------------------------------------------------------- /spec/cassettes/4.5/single_post_auth.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/posts/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="831499db0e3d1490b4c1cb7446fbb14b", 14 | oauth_signature="t%2FdNxoN9wUeYrKYRCSBW%2FaTWzbU%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1461005368", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | response: 17 | status: 18 | code: 200 19 | message: OK 20 | headers: 21 | Host: 22 | - localhost:8080 23 | Connection: 24 | - close 25 | X-Powered-By: 26 | - PHP/5.6.9 27 | Content-Type: 28 | - application/json; charset=UTF-8 29 | X-Content-Type-Options: 30 | - nosniff 31 | Access-Control-Expose-Headers: 32 | - X-WP-Total, X-WP-TotalPages 33 | Access-Control-Allow-Headers: 34 | - Authorization 35 | Expires: 36 | - Wed, 11 Jan 1984 05:00:00 GMT 37 | Cache-Control: 38 | - no-cache, must-revalidate, max-age=0 39 | Pragma: 40 | - no-cache 41 | Last-Modified: 42 | - '' 43 | Link: 44 | - ; rel="alternate"; type=text/html 45 | Allow: 46 | - GET, POST, PUT, PATCH, DELETE 47 | body: 48 | encoding: UTF-8 49 | string: '{"id":1,"date":"2016-03-30T00:20:00","date_gmt":"2016-03-30T00:20:00","guid":{"rendered":"http:\/\/localhost:8080\/?p=1"},"modified":"2016-03-30T00:20:00","modified_gmt":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 50 | world!"},"content":{"rendered":"

Welcome to WordPress. This is your first 51 | post. Edit or delete it, then start writing!<\/p>\n"},"excerpt":{"rendered":"

Welcome 52 | to WordPress. This is your first post. Edit or delete it, then start writing!<\/p>\n"},"author":1,"featured_media":203,"comment_status":"open","ping_status":"open","sticky":false,"format":"standard","categories":[1],"tags":[],"custom_taxonomy":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]},"_embedded":{"author":[{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}],"replies":[[{"id":1,"parent":0,"author":0,"author_name":"Mr 53 | WordPress","author_url":"https:\/\/wordpress.org\/","author_avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/?s=24&d=mm&r=g","48":"http:\/\/2.gravatar.com\/avatar\/?s=48&d=mm&r=g","96":"http:\/\/1.gravatar.com\/avatar\/?s=96&d=mm&r=g"},"date":"2016-03-30T00:20:00","content":{"rendered":"

Hi, 54 | this is a comment.
\nTo delete a comment, just log in and view the post's 55 | comments. There you will have the option to edit or delete them.<\/p>\n"},"link":"http:\/\/localhost:8080\/%post%\/#comment-1","type":"comment","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments"}],"up":[{"embeddable":true,"post_type":"post","href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]}}]],"wp:featuredmedia":[{"id":203,"date":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"alt_text":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}],"wp:term":[[{"id":1,"link":"http:\/\/localhost:8080\/category\/uncategorized\/","name":"Uncategorized","slug":"uncategorized","taxonomy":"category","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/category"}],"http:\/\/api.w.org\/v2\/post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?categories=1"}]}}],[],[]],"wp:meta":[{"code":"rest_invalid_param","message":"Invalid 56 | parameter(s): context","data":{"status":400,"params":{"context":"context is 57 | not one of edit"}}}]}}' 58 | http_version: 59 | recorded_at: Mon, 18 Apr 2016 18:49:28 GMT 60 | - request: 61 | method: get 62 | uri: http://localhost:8080/wp-json/wp/v2/posts/1/meta?_embed=true 63 | body: 64 | encoding: US-ASCII 65 | string: '' 66 | headers: 67 | User-Agent: 68 | - Faraday v0.9.2 69 | Authorization: 70 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="5ac89f55ad3e815b345208843135bf51", 71 | oauth_signature="UPcZEWIeKsoTIe%2FdepmUEXMFTbU%3D", oauth_signature_method="HMAC-SHA1", 72 | oauth_timestamp="1461006481", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 73 | response: 74 | status: 75 | code: 200 76 | message: OK 77 | headers: 78 | Host: 79 | - localhost:8080 80 | Connection: 81 | - close 82 | X-Powered-By: 83 | - PHP/5.6.9 84 | Content-Type: 85 | - application/json; charset=UTF-8 86 | X-Content-Type-Options: 87 | - nosniff 88 | Access-Control-Expose-Headers: 89 | - X-WP-Total, X-WP-TotalPages 90 | Access-Control-Allow-Headers: 91 | - Authorization 92 | Expires: 93 | - Wed, 11 Jan 1984 05:00:00 GMT 94 | Cache-Control: 95 | - no-cache, must-revalidate, max-age=0 96 | Pragma: 97 | - no-cache 98 | Last-Modified: 99 | - '' 100 | Allow: 101 | - GET, POST 102 | body: 103 | encoding: UTF-8 104 | string: '[{"id":205,"key":"example_metadata_field","value":"example_meta_value","_links":{"about":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]},"_embedded":{"about":[{"id":1,"date":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 105 | world!"},"excerpt":{"rendered":"

Welcome to WordPress. This is your first 106 | post. Edit or delete it, then start writing!<\/p>\n"},"author":1,"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]}},{"id":206,"key":"example_associated_post_id","value":"100","_links":{"about":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]},"_embedded":{"about":[{"id":1,"date":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 107 | world!"},"excerpt":{"rendered":"

Welcome to WordPress. This is your first 108 | post. Edit or delete it, then start writing!<\/p>\n"},"author":1,"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]}}]' 109 | http_version: 110 | recorded_at: Mon, 18 Apr 2016 19:08:01 GMT 111 | recorded_with: VCR 3.0.1 112 | -------------------------------------------------------------------------------- /spec/cassettes/4.5/single_taxonomy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/taxonomies/custom_taxonomy?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="04ad7ad2ab87865c8721fe1b1b5852e4", 14 | oauth_signature="A3qwgCFQ1vOqWiLJdtz%2BjKL2%2Bic%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1461005369", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | response: 17 | status: 18 | code: 200 19 | message: OK 20 | headers: 21 | Host: 22 | - localhost:8080 23 | Connection: 24 | - close 25 | X-Powered-By: 26 | - PHP/5.6.9 27 | Content-Type: 28 | - application/json; charset=UTF-8 29 | X-Content-Type-Options: 30 | - nosniff 31 | Access-Control-Expose-Headers: 32 | - X-WP-Total, X-WP-TotalPages 33 | Access-Control-Allow-Headers: 34 | - Authorization 35 | Expires: 36 | - Wed, 11 Jan 1984 05:00:00 GMT 37 | Cache-Control: 38 | - no-cache, must-revalidate, max-age=0 39 | Pragma: 40 | - no-cache 41 | Last-Modified: 42 | - '' 43 | Allow: 44 | - GET 45 | body: 46 | encoding: UTF-8 47 | string: '{"name":"Custom taxonomy","slug":"custom_taxonomy","description":"","types":["custom_post_type","post"],"hierarchical":false,"_links":{"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies"}],"wp:items":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}' 48 | http_version: 49 | recorded_at: Mon, 18 Apr 2016 18:49:29 GMT 50 | - request: 51 | method: get 52 | uri: http://localhost:8080/wp-json/wp/v2/custom_taxonomy?_embed=true 53 | body: 54 | encoding: US-ASCII 55 | string: '' 56 | headers: 57 | User-Agent: 58 | - Faraday v0.9.2 59 | Authorization: 60 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="079b5eccadf2421a76cc3129db90c6bc", 61 | oauth_signature="a9w%2Fyu4O4sF7Y2PDKQS89illF94%3D", oauth_signature_method="HMAC-SHA1", 62 | oauth_timestamp="1461006481", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 63 | response: 64 | status: 65 | code: 200 66 | message: OK 67 | headers: 68 | Host: 69 | - localhost:8080 70 | Connection: 71 | - close 72 | X-Powered-By: 73 | - PHP/5.6.9 74 | Content-Type: 75 | - application/json; charset=UTF-8 76 | X-Content-Type-Options: 77 | - nosniff 78 | Access-Control-Expose-Headers: 79 | - X-WP-Total, X-WP-TotalPages 80 | Access-Control-Allow-Headers: 81 | - Authorization 82 | Expires: 83 | - Wed, 11 Jan 1984 05:00:00 GMT 84 | Cache-Control: 85 | - no-cache, must-revalidate, max-age=0 86 | Pragma: 87 | - no-cache 88 | Last-Modified: 89 | - '' 90 | X-Wp-Total: 91 | - '2' 92 | X-Wp-Totalpages: 93 | - '1' 94 | Allow: 95 | - GET, POST 96 | body: 97 | encoding: UTF-8 98 | string: '[{"id":2,"count":20,"description":"","link":"http:\/\/localhost:8080\/custom_taxonomy\/term_one\/","name":"term_one","slug":"term_one","taxonomy":"custom_taxonomy","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy\/2"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/custom_taxonomy"}],"http:\/\/api.w.org\/v2\/post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_post_type?custom_taxonomy=2"},{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?custom_taxonomy=2"}]}},{"id":3,"count":10,"description":"","link":"http:\/\/localhost:8080\/custom_taxonomy\/term_two\/","name":"term_two","slug":"term_two","taxonomy":"custom_taxonomy","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy\/3"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/custom_taxonomy"}],"http:\/\/api.w.org\/v2\/post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_post_type?custom_taxonomy=3"},{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?custom_taxonomy=3"}]}}]' 99 | http_version: 100 | recorded_at: Mon, 18 Apr 2016 19:08:02 GMT 101 | recorded_with: VCR 3.0.1 102 | -------------------------------------------------------------------------------- /spec/cassettes/4.5/single_user.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/users/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.9.2 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="32f8aca2ac064b62b9744f3f5d1bc45c", 14 | oauth_signature="sk5nSbmMjOLW%2FbnQ%2FnoE6SDkI8o%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1469636075", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.21 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Content-Type-Options: 32 | - nosniff 33 | Access-Control-Expose-Headers: 34 | - X-WP-Total, X-WP-TotalPages 35 | Access-Control-Allow-Headers: 36 | - Authorization 37 | Expires: 38 | - Wed, 11 Jan 1984 05:00:00 GMT 39 | Cache-Control: 40 | - no-cache, must-revalidate, max-age=0 41 | Pragma: 42 | - no-cache 43 | Last-Modified: 44 | - '' 45 | Allow: 46 | - GET, POST, PUT, PATCH, DELETE 47 | body: 48 | encoding: UTF-8 49 | string: '{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}' 50 | http_version: 51 | recorded_at: Wed, 27 Jul 2016 16:14:36 GMT 52 | recorded_with: VCR 3.0.3 53 | -------------------------------------------------------------------------------- /spec/cassettes/4.7.2/oauth_test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/posts/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.11.0 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="aadcc7658424d41e343222300316451a", 14 | oauth_signature="i%2BECXkUVhoFN3oaAQMr28b1Rb0g%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1487630292", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.26 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Robots-Tag: 32 | - noindex 33 | X-Content-Type-Options: 34 | - nosniff 35 | Access-Control-Expose-Headers: 36 | - X-WP-Total, X-WP-TotalPages 37 | Access-Control-Allow-Headers: 38 | - Authorization, Content-Type 39 | Expires: 40 | - Wed, 11 Jan 1984 05:00:00 GMT 41 | Cache-Control: 42 | - no-cache, must-revalidate, max-age=0 43 | Last-Modified: 44 | - '' 45 | Link: 46 | - ; rel="alternate"; type=text/html 47 | Allow: 48 | - GET, POST, PUT, PATCH, DELETE 49 | body: 50 | encoding: UTF-8 51 | string: '{"id":1,"date":"2016-03-30T00:20:00","date_gmt":"2016-03-30T00:20:00","guid":{"rendered":"http:\/\/localhost:8080\/?p=1"},"modified":"2016-03-30T00:20:00","modified_gmt":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 52 | world!"},"content":{"rendered":"

Welcome to WordPress. This is your first 53 | post. Edit or delete it, then start writing!<\/p>\n","protected":false},"excerpt":{"rendered":"

Welcome 54 | to WordPress. This is your first post. Edit or delete it, then start writing!<\/p>\n","protected":false},"author":1,"featured_media":203,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"custom_taxonomy":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]},"_embedded":{"author":[{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}],"replies":[[{"id":1,"parent":0,"author":0,"author_name":"Mr 55 | WordPress","author_url":"https:\/\/wordpress.org\/","date":"2016-03-30T00:20:00","content":{"rendered":"

Hi, 56 | this is a comment.
\nTo delete a comment, just log in and view the post's 57 | comments. There you will have the option to edit or delete them.<\/p>\n"},"link":"http:\/\/localhost:8080\/%post%\/#comment-1","type":"comment","author_avatar_urls":{"24":"http:\/\/1.gravatar.com\/avatar\/?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments"}],"up":[{"embeddable":true,"post_type":"post","href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]}}]],"wp:featuredmedia":[{"id":203,"date":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"caption":{"rendered":""},"alt_text":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}],"wp:term":[[{"id":1,"link":"http:\/\/localhost:8080\/category\/uncategorized\/","name":"Uncategorized","slug":"uncategorized","taxonomy":"category","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/category"}],"wp:post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?categories=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}],[],[]],"wp:meta":[{"code":"rest_invalid_param","message":"Invalid 58 | parameter(s): context","data":{"status":400,"params":{"context":"context is 59 | not one of edit."}}}]}}' 60 | http_version: 61 | recorded_at: Mon, 20 Feb 2017 22:38:12 GMT 62 | recorded_with: VCR 3.0.3 63 | -------------------------------------------------------------------------------- /spec/cassettes/4.7.2/single_image.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/media/203?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.11.0 12 | Expect: 13 | - '' 14 | response: 15 | status: 16 | code: 200 17 | message: OK 18 | headers: 19 | Host: 20 | - localhost:8080 21 | Connection: 22 | - close 23 | X-Powered-By: 24 | - PHP/5.6.26 25 | Content-Type: 26 | - application/json; charset=UTF-8 27 | X-Robots-Tag: 28 | - noindex 29 | X-Content-Type-Options: 30 | - nosniff 31 | Access-Control-Expose-Headers: 32 | - X-WP-Total, X-WP-TotalPages 33 | Access-Control-Allow-Headers: 34 | - Authorization, Content-Type 35 | Link: 36 | - ; rel="alternate"; type=text/html 37 | Allow: 38 | - GET 39 | body: 40 | encoding: UTF-8 41 | string: '{"id":203,"date":"2016-03-30T00:20:04","date_gmt":"2016-03-30T00:20:04","guid":{"rendered":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"},"modified":"2016-03-30T00:20:04","modified_gmt":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"comment_status":"open","ping_status":"closed","template":"","meta":[],"description":{"rendered":"

\"\"<\/a><\/p>\n"},"caption":{"rendered":""},"alt_text":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"post":null,"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}' 47 | http_version: 48 | recorded_at: Mon, 20 Feb 2017 22:38:07 GMT 49 | recorded_with: VCR 3.0.3 50 | -------------------------------------------------------------------------------- /spec/cassettes/4.7.2/single_post_auth.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/posts/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.11.0 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="752e840033a15f84b297f5c30b947b57", 14 | oauth_signature="g%2BMRoGCaG%2BqEX8xrVelVE2na%2FIY%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1487630288", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.26 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Robots-Tag: 32 | - noindex 33 | X-Content-Type-Options: 34 | - nosniff 35 | Access-Control-Expose-Headers: 36 | - X-WP-Total, X-WP-TotalPages 37 | Access-Control-Allow-Headers: 38 | - Authorization, Content-Type 39 | Expires: 40 | - Wed, 11 Jan 1984 05:00:00 GMT 41 | Cache-Control: 42 | - no-cache, must-revalidate, max-age=0 43 | Last-Modified: 44 | - '' 45 | Link: 46 | - ; rel="alternate"; type=text/html 47 | Allow: 48 | - GET, POST, PUT, PATCH, DELETE 49 | body: 50 | encoding: UTF-8 51 | string: '{"id":1,"date":"2016-03-30T00:20:00","date_gmt":"2016-03-30T00:20:00","guid":{"rendered":"http:\/\/localhost:8080\/?p=1"},"modified":"2016-03-30T00:20:00","modified_gmt":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 52 | world!"},"content":{"rendered":"

Welcome to WordPress. This is your first 53 | post. Edit or delete it, then start writing!<\/p>\n","protected":false},"excerpt":{"rendered":"

Welcome 54 | to WordPress. This is your first post. Edit or delete it, then start writing!<\/p>\n","protected":false},"author":1,"featured_media":203,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"custom_taxonomy":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]},"_embedded":{"author":[{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}],"replies":[[{"id":1,"parent":0,"author":0,"author_name":"Mr 55 | WordPress","author_url":"https:\/\/wordpress.org\/","date":"2016-03-30T00:20:00","content":{"rendered":"

Hi, 56 | this is a comment.
\nTo delete a comment, just log in and view the post's 57 | comments. There you will have the option to edit or delete them.<\/p>\n"},"link":"http:\/\/localhost:8080\/%post%\/#comment-1","type":"comment","author_avatar_urls":{"24":"http:\/\/1.gravatar.com\/avatar\/?s=24&d=mm&r=g","48":"http:\/\/1.gravatar.com\/avatar\/?s=48&d=mm&r=g","96":"http:\/\/2.gravatar.com\/avatar\/?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments"}],"up":[{"embeddable":true,"post_type":"post","href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]}}]],"wp:featuredmedia":[{"id":203,"date":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"caption":{"rendered":""},"alt_text":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}],"wp:term":[[{"id":1,"link":"http:\/\/localhost:8080\/category\/uncategorized\/","name":"Uncategorized","slug":"uncategorized","taxonomy":"category","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/category"}],"wp:post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?categories=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}],[],[]],"wp:meta":[{"code":"rest_invalid_param","message":"Invalid 58 | parameter(s): context","data":{"status":400,"params":{"context":"context is 59 | not one of edit."}}}]}}' 60 | http_version: 61 | recorded_at: Mon, 20 Feb 2017 22:38:08 GMT 62 | - request: 63 | method: get 64 | uri: http://localhost:8080/wp-json/wp/v2/posts/1/meta?_embed=true 65 | body: 66 | encoding: US-ASCII 67 | string: '' 68 | headers: 69 | User-Agent: 70 | - Faraday v0.11.0 71 | Authorization: 72 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="b7fd3dee853ce4c5fd8f289e152ca67f", 73 | oauth_signature="01XF5t1EcZUjcxf2GOQ5p0FiLhk%3D", oauth_signature_method="HMAC-SHA1", 74 | oauth_timestamp="1487630288", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 75 | Expect: 76 | - '' 77 | response: 78 | status: 79 | code: 200 80 | message: OK 81 | headers: 82 | Host: 83 | - localhost:8080 84 | Connection: 85 | - close 86 | X-Powered-By: 87 | - PHP/5.6.26 88 | Content-Type: 89 | - application/json; charset=UTF-8 90 | X-Robots-Tag: 91 | - noindex 92 | Link: 93 | - ; rel="https://api.w.org/" 94 | X-Content-Type-Options: 95 | - nosniff 96 | Access-Control-Expose-Headers: 97 | - X-WP-Total, X-WP-TotalPages 98 | Access-Control-Allow-Headers: 99 | - Authorization, Content-Type 100 | Expires: 101 | - Wed, 11 Jan 1984 05:00:00 GMT 102 | Cache-Control: 103 | - no-cache, must-revalidate, max-age=0 104 | Last-Modified: 105 | - '' 106 | Allow: 107 | - GET, POST 108 | body: 109 | encoding: UTF-8 110 | string: '[{"id":205,"key":"example_metadata_field","value":"example_meta_value","_links":{"about":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]},"_embedded":{"about":[{"id":1,"date":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 111 | world!"},"excerpt":{"rendered":"

Welcome to WordPress. This is your first 112 | post. Edit or delete it, then start writing!<\/p>\n","protected":false},"author":1,"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]}},{"id":206,"key":"example_associated_post_id","value":"100","_links":{"about":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]},"_embedded":{"about":[{"id":1,"date":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 113 | world!"},"excerpt":{"rendered":"

Welcome to WordPress. This is your first 114 | post. Edit or delete it, then start writing!<\/p>\n","protected":false},"author":1,"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]}}]' 115 | http_version: 116 | recorded_at: Mon, 20 Feb 2017 22:38:08 GMT 117 | recorded_with: VCR 3.0.3 118 | -------------------------------------------------------------------------------- /spec/cassettes/4.7.2/single_taxonomy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/taxonomies/custom_taxonomy?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.11.0 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="68ac546c874b492bc981c5b3a0c9017f", 14 | oauth_signature="cS6t4QSHXRYtc6PTUiac1vuU%2FZY%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1487630289", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.26 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Robots-Tag: 32 | - noindex 33 | Link: 34 | - ; rel="https://api.w.org/" 35 | X-Content-Type-Options: 36 | - nosniff 37 | Access-Control-Expose-Headers: 38 | - X-WP-Total, X-WP-TotalPages 39 | Access-Control-Allow-Headers: 40 | - Authorization, Content-Type 41 | Expires: 42 | - Wed, 11 Jan 1984 05:00:00 GMT 43 | Cache-Control: 44 | - no-cache, must-revalidate, max-age=0 45 | Last-Modified: 46 | - '' 47 | Allow: 48 | - GET 49 | body: 50 | encoding: UTF-8 51 | string: '{"name":"Custom taxonomy","slug":"custom_taxonomy","description":"","types":["custom_post_type","post"],"hierarchical":false,"rest_base":"custom_taxonomy","_links":{"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies"}],"wp:items":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}' 52 | http_version: 53 | recorded_at: Mon, 20 Feb 2017 22:38:09 GMT 54 | - request: 55 | method: get 56 | uri: http://localhost:8080/wp-json/wp/v2/custom_taxonomy?_embed=true 57 | body: 58 | encoding: US-ASCII 59 | string: '' 60 | headers: 61 | User-Agent: 62 | - Faraday v0.11.0 63 | Authorization: 64 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="d2f5bca200ba2d22a4950d9577ea93bf", 65 | oauth_signature="Tf%2FaP9LGhTS5wWhZSlDIO3F7rNk%3D", oauth_signature_method="HMAC-SHA1", 66 | oauth_timestamp="1487630289", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 67 | Expect: 68 | - '' 69 | response: 70 | status: 71 | code: 200 72 | message: OK 73 | headers: 74 | Host: 75 | - localhost:8080 76 | Connection: 77 | - close 78 | X-Powered-By: 79 | - PHP/5.6.26 80 | Content-Type: 81 | - application/json; charset=UTF-8 82 | X-Robots-Tag: 83 | - noindex 84 | Link: 85 | - ; rel="https://api.w.org/" 86 | X-Content-Type-Options: 87 | - nosniff 88 | Access-Control-Expose-Headers: 89 | - X-WP-Total, X-WP-TotalPages 90 | Access-Control-Allow-Headers: 91 | - Authorization, Content-Type 92 | Expires: 93 | - Wed, 11 Jan 1984 05:00:00 GMT 94 | Cache-Control: 95 | - no-cache, must-revalidate, max-age=0 96 | Last-Modified: 97 | - '' 98 | X-Wp-Total: 99 | - '2' 100 | X-Wp-Totalpages: 101 | - '1' 102 | Allow: 103 | - GET, POST 104 | body: 105 | encoding: UTF-8 106 | string: '[{"id":2,"count":20,"description":"","link":"http:\/\/localhost:8080\/custom_taxonomy\/term_one\/","name":"term_one","slug":"term_one","taxonomy":"custom_taxonomy","meta":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy\/2"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/custom_taxonomy"}],"wp:post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_post_type?custom_taxonomy=2"},{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?custom_taxonomy=2"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}},{"id":3,"count":10,"description":"","link":"http:\/\/localhost:8080\/custom_taxonomy\/term_two\/","name":"term_two","slug":"term_two","taxonomy":"custom_taxonomy","meta":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy\/3"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/custom_taxonomy"}],"wp:post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_post_type?custom_taxonomy=3"},{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?custom_taxonomy=3"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]' 107 | http_version: 108 | recorded_at: Mon, 20 Feb 2017 22:38:10 GMT 109 | recorded_with: VCR 3.0.3 110 | -------------------------------------------------------------------------------- /spec/cassettes/4.7.2/single_user.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/users/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.11.0 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="86581b5b17fd2e5cb974fc4c30f7a5e3", 14 | oauth_signature="dyRN3ncp431tUISBHghS43WXv6A%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1487630291", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.26 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Robots-Tag: 32 | - noindex 33 | Link: 34 | - ; rel="https://api.w.org/" 35 | X-Content-Type-Options: 36 | - nosniff 37 | Access-Control-Expose-Headers: 38 | - X-WP-Total, X-WP-TotalPages 39 | Access-Control-Allow-Headers: 40 | - Authorization, Content-Type 41 | Expires: 42 | - Wed, 11 Jan 1984 05:00:00 GMT 43 | Cache-Control: 44 | - no-cache, must-revalidate, max-age=0 45 | Last-Modified: 46 | - '' 47 | Allow: 48 | - GET, POST, PUT, PATCH, DELETE 49 | body: 50 | encoding: UTF-8 51 | string: '{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"meta":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}' 52 | http_version: 53 | recorded_at: Mon, 20 Feb 2017 22:38:12 GMT 54 | recorded_with: VCR 3.0.3 55 | -------------------------------------------------------------------------------- /spec/cassettes/4.7/oauth_test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/posts/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.11.0 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="11acb772087307b4fe8751bdcbffa430", 14 | oauth_signature="sjIQzhze%2FKcqsYpqOvNKR4xzutA%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1487629007", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.26 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Robots-Tag: 32 | - noindex 33 | X-Content-Type-Options: 34 | - nosniff 35 | Access-Control-Expose-Headers: 36 | - X-WP-Total, X-WP-TotalPages 37 | Access-Control-Allow-Headers: 38 | - Authorization, Content-Type 39 | Expires: 40 | - Wed, 11 Jan 1984 05:00:00 GMT 41 | Cache-Control: 42 | - no-cache, must-revalidate, max-age=0 43 | Last-Modified: 44 | - '' 45 | Link: 46 | - ; rel="alternate"; type=text/html 47 | Allow: 48 | - GET, POST, PUT, PATCH, DELETE 49 | body: 50 | encoding: UTF-8 51 | string: '{"id":1,"date":"2016-03-30T00:20:00","date_gmt":"2016-03-30T00:20:00","guid":{"rendered":"http:\/\/localhost:8080\/?p=1"},"modified":"2016-03-30T00:20:00","modified_gmt":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 52 | world!"},"content":{"rendered":"

Welcome to WordPress. This is your first 53 | post. Edit or delete it, then start writing!<\/p>\n","protected":false},"excerpt":{"rendered":"

Welcome 54 | to WordPress. This is your first post. Edit or delete it, then start writing!<\/p>\n","protected":false},"author":1,"featured_media":203,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"custom_taxonomy":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]},"_embedded":{"author":[{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}],"replies":[[{"id":1,"parent":0,"author":0,"author_name":"Mr 55 | WordPress","author_url":"https:\/\/wordpress.org\/","date":"2016-03-30T00:20:00","content":{"rendered":"

Hi, 56 | this is a comment.
\nTo delete a comment, just log in and view the post's 57 | comments. There you will have the option to edit or delete them.<\/p>\n"},"link":"http:\/\/localhost:8080\/%post%\/#comment-1","type":"comment","author_avatar_urls":{"24":"http:\/\/2.gravatar.com\/avatar\/?s=24&d=mm&r=g","48":"http:\/\/2.gravatar.com\/avatar\/?s=48&d=mm&r=g","96":"http:\/\/1.gravatar.com\/avatar\/?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments"}],"up":[{"embeddable":true,"post_type":"post","href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]}}]],"wp:featuredmedia":[{"id":203,"date":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"caption":{"rendered":""},"alt_text":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}],"wp:term":[[{"id":1,"link":"http:\/\/localhost:8080\/category\/uncategorized\/","name":"Uncategorized","slug":"uncategorized","taxonomy":"category","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/category"}],"wp:post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?categories=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}],[],[]],"wp:meta":[{"code":"rest_invalid_param","message":"Invalid 58 | parameter(s): context","data":{"status":400,"params":{"context":"context is 59 | not one of edit."}}}]}}' 60 | http_version: 61 | recorded_at: Mon, 20 Feb 2017 22:16:47 GMT 62 | recorded_with: VCR 3.0.3 63 | -------------------------------------------------------------------------------- /spec/cassettes/4.7/single_image.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/media/203?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.11.0 12 | Expect: 13 | - '' 14 | response: 15 | status: 16 | code: 200 17 | message: OK 18 | headers: 19 | Host: 20 | - localhost:8080 21 | Connection: 22 | - close 23 | X-Powered-By: 24 | - PHP/5.6.26 25 | Content-Type: 26 | - application/json; charset=UTF-8 27 | X-Robots-Tag: 28 | - noindex 29 | X-Content-Type-Options: 30 | - nosniff 31 | Access-Control-Expose-Headers: 32 | - X-WP-Total, X-WP-TotalPages 33 | Access-Control-Allow-Headers: 34 | - Authorization, Content-Type 35 | Link: 36 | - ; rel="alternate"; type=text/html 37 | Allow: 38 | - GET 39 | body: 40 | encoding: UTF-8 41 | string: '{"id":203,"date":"2016-03-30T00:20:04","date_gmt":"2016-03-30T00:20:04","guid":{"rendered":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"},"modified":"2016-03-30T00:20:04","modified_gmt":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"comment_status":"open","ping_status":"closed","template":"","meta":[],"description":{"rendered":"

\"\"<\/a><\/p>\n"},"caption":{"rendered":""},"alt_text":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"post":null,"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}' 47 | http_version: 48 | recorded_at: Mon, 20 Feb 2017 22:16:43 GMT 49 | recorded_with: VCR 3.0.3 50 | -------------------------------------------------------------------------------- /spec/cassettes/4.7/single_post_auth.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/posts/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.11.0 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="1dd79f88037441750c11c5fad258744e", 14 | oauth_signature="l6ueHb2EwWJWipZ9V324IEjBBZ4%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1487629003", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.26 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Robots-Tag: 32 | - noindex 33 | X-Content-Type-Options: 34 | - nosniff 35 | Access-Control-Expose-Headers: 36 | - X-WP-Total, X-WP-TotalPages 37 | Access-Control-Allow-Headers: 38 | - Authorization, Content-Type 39 | Expires: 40 | - Wed, 11 Jan 1984 05:00:00 GMT 41 | Cache-Control: 42 | - no-cache, must-revalidate, max-age=0 43 | Last-Modified: 44 | - '' 45 | Link: 46 | - ; rel="alternate"; type=text/html 47 | Allow: 48 | - GET, POST, PUT, PATCH, DELETE 49 | body: 50 | encoding: UTF-8 51 | string: '{"id":1,"date":"2016-03-30T00:20:00","date_gmt":"2016-03-30T00:20:00","guid":{"rendered":"http:\/\/localhost:8080\/?p=1"},"modified":"2016-03-30T00:20:00","modified_gmt":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 52 | world!"},"content":{"rendered":"

Welcome to WordPress. This is your first 53 | post. Edit or delete it, then start writing!<\/p>\n","protected":false},"excerpt":{"rendered":"

Welcome 54 | to WordPress. This is your first post. Edit or delete it, then start writing!<\/p>\n","protected":false},"author":1,"featured_media":203,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"custom_taxonomy":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]},"_embedded":{"author":[{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}],"replies":[[{"id":1,"parent":0,"author":0,"author_name":"Mr 55 | WordPress","author_url":"https:\/\/wordpress.org\/","date":"2016-03-30T00:20:00","content":{"rendered":"

Hi, 56 | this is a comment.
\nTo delete a comment, just log in and view the post's 57 | comments. There you will have the option to edit or delete them.<\/p>\n"},"link":"http:\/\/localhost:8080\/%post%\/#comment-1","type":"comment","author_avatar_urls":{"24":"http:\/\/1.gravatar.com\/avatar\/?s=24&d=mm&r=g","48":"http:\/\/2.gravatar.com\/avatar\/?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/?s=96&d=mm&r=g"},"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments"}],"up":[{"embeddable":true,"post_type":"post","href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]}}]],"wp:featuredmedia":[{"id":203,"date":"2016-03-30T00:20:04","slug":"203","type":"attachment","link":"http:\/\/localhost:8080\/203\/","title":{"rendered":""},"author":0,"caption":{"rendered":""},"alt_text":"","media_type":"image","mime_type":"image\/png","media_details":{"width":350,"height":150,"file":"2016\/03\/image-9.png","sizes":{"thumbnail":{"file":"image-9-150x150.png","width":150,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-150x150.png"},"medium":{"file":"image-9-300x129.png","width":300,"height":129,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9-300x129.png"},"full":{"file":"image-9.png","width":350,"height":150,"mime_type":"image\/png","source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png"}},"image_meta":{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0","keywords":[]}},"source_url":"http:\/\/localhost:8080\/app\/uploads\/2016\/03\/image-9.png","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/attachment"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=203"}]}}],"wp:term":[[{"id":1,"link":"http:\/\/localhost:8080\/category\/uncategorized\/","name":"Uncategorized","slug":"uncategorized","taxonomy":"category","_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/category"}],"wp:post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?categories=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}],[],[]],"wp:meta":[{"code":"rest_invalid_param","message":"Invalid 58 | parameter(s): context","data":{"status":400,"params":{"context":"context is 59 | not one of edit."}}}]}}' 60 | http_version: 61 | recorded_at: Mon, 20 Feb 2017 22:16:43 GMT 62 | - request: 63 | method: get 64 | uri: http://localhost:8080/wp-json/wp/v2/posts/1/meta?_embed=true 65 | body: 66 | encoding: US-ASCII 67 | string: '' 68 | headers: 69 | User-Agent: 70 | - Faraday v0.11.0 71 | Authorization: 72 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="7f970f68185b4c96c9cf0ec271b5f01b", 73 | oauth_signature="5jalhTGBnsOW44PD%2BtLkuR%2BVwfU%3D", oauth_signature_method="HMAC-SHA1", 74 | oauth_timestamp="1487629003", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 75 | Expect: 76 | - '' 77 | response: 78 | status: 79 | code: 200 80 | message: OK 81 | headers: 82 | Host: 83 | - localhost:8080 84 | Connection: 85 | - close 86 | X-Powered-By: 87 | - PHP/5.6.26 88 | Content-Type: 89 | - application/json; charset=UTF-8 90 | X-Robots-Tag: 91 | - noindex 92 | Link: 93 | - ; rel="https://api.w.org/" 94 | X-Content-Type-Options: 95 | - nosniff 96 | Access-Control-Expose-Headers: 97 | - X-WP-Total, X-WP-TotalPages 98 | Access-Control-Allow-Headers: 99 | - Authorization, Content-Type 100 | Expires: 101 | - Wed, 11 Jan 1984 05:00:00 GMT 102 | Cache-Control: 103 | - no-cache, must-revalidate, max-age=0 104 | Last-Modified: 105 | - '' 106 | Allow: 107 | - GET, POST 108 | body: 109 | encoding: UTF-8 110 | string: '[{"id":205,"key":"example_metadata_field","value":"example_meta_value","_links":{"about":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]},"_embedded":{"about":[{"id":1,"date":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 111 | world!"},"excerpt":{"rendered":"

Welcome to WordPress. This is your first 112 | post. Edit or delete it, then start writing!<\/p>\n","protected":false},"author":1,"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]}},{"id":206,"key":"example_associated_post_id","value":"100","_links":{"about":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}]},"_embedded":{"about":[{"id":1,"date":"2016-03-30T00:20:00","slug":"hello-world","type":"post","link":"http:\/\/localhost:8080\/%post%\/","title":{"rendered":"Hello 113 | world!"},"excerpt":{"rendered":"

Welcome to WordPress. This is your first 114 | post. Edit or delete it, then start writing!<\/p>\n","protected":false},"author":1,"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media\/203"}],"wp:attachment":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/tags?post=1"},{"taxonomy":"custom_taxonomy","embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy?post=1"}],"wp:meta":[{"embeddable":true,"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts\/1\/meta"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]}}]' 115 | http_version: 116 | recorded_at: Mon, 20 Feb 2017 22:16:44 GMT 117 | recorded_with: VCR 3.0.3 118 | -------------------------------------------------------------------------------- /spec/cassettes/4.7/single_taxonomy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/taxonomies/custom_taxonomy?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.11.0 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="f653a2bd91184529c8349b70b3901d5f", 14 | oauth_signature="%2BUn83%2Bn6KcCulUk8H2iDoM9qYwA%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1487629004", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.26 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Robots-Tag: 32 | - noindex 33 | Link: 34 | - ; rel="https://api.w.org/" 35 | X-Content-Type-Options: 36 | - nosniff 37 | Access-Control-Expose-Headers: 38 | - X-WP-Total, X-WP-TotalPages 39 | Access-Control-Allow-Headers: 40 | - Authorization, Content-Type 41 | Expires: 42 | - Wed, 11 Jan 1984 05:00:00 GMT 43 | Cache-Control: 44 | - no-cache, must-revalidate, max-age=0 45 | Last-Modified: 46 | - '' 47 | Allow: 48 | - GET 49 | body: 50 | encoding: UTF-8 51 | string: '{"name":"Custom taxonomy","slug":"custom_taxonomy","description":"","types":["custom_post_type","post"],"hierarchical":false,"rest_base":"custom_taxonomy","_links":{"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies"}],"wp:items":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}' 52 | http_version: 53 | recorded_at: Mon, 20 Feb 2017 22:16:45 GMT 54 | - request: 55 | method: get 56 | uri: http://localhost:8080/wp-json/wp/v2/custom_taxonomy?_embed=true 57 | body: 58 | encoding: US-ASCII 59 | string: '' 60 | headers: 61 | User-Agent: 62 | - Faraday v0.11.0 63 | Authorization: 64 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="a9a1cc1ddea91c428f975c92c8de812a", 65 | oauth_signature="XMWSUtz8hIisRfMxDLVrn0PMjcg%3D", oauth_signature_method="HMAC-SHA1", 66 | oauth_timestamp="1487629005", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 67 | Expect: 68 | - '' 69 | response: 70 | status: 71 | code: 200 72 | message: OK 73 | headers: 74 | Host: 75 | - localhost:8080 76 | Connection: 77 | - close 78 | X-Powered-By: 79 | - PHP/5.6.26 80 | Content-Type: 81 | - application/json; charset=UTF-8 82 | X-Robots-Tag: 83 | - noindex 84 | Link: 85 | - ; rel="https://api.w.org/" 86 | X-Content-Type-Options: 87 | - nosniff 88 | Access-Control-Expose-Headers: 89 | - X-WP-Total, X-WP-TotalPages 90 | Access-Control-Allow-Headers: 91 | - Authorization, Content-Type 92 | Expires: 93 | - Wed, 11 Jan 1984 05:00:00 GMT 94 | Cache-Control: 95 | - no-cache, must-revalidate, max-age=0 96 | Last-Modified: 97 | - '' 98 | X-Wp-Total: 99 | - '2' 100 | X-Wp-Totalpages: 101 | - '1' 102 | Allow: 103 | - GET, POST 104 | body: 105 | encoding: UTF-8 106 | string: '[{"id":2,"count":20,"description":"","link":"http:\/\/localhost:8080\/custom_taxonomy\/term_one\/","name":"term_one","slug":"term_one","taxonomy":"custom_taxonomy","meta":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy\/2"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/custom_taxonomy"}],"wp:post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_post_type?custom_taxonomy=2"},{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?custom_taxonomy=2"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}},{"id":3,"count":10,"description":"","link":"http:\/\/localhost:8080\/custom_taxonomy\/term_two\/","name":"term_two","slug":"term_two","taxonomy":"custom_taxonomy","meta":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy\/3"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_taxonomy"}],"about":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/taxonomies\/custom_taxonomy"}],"wp:post_type":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/custom_post_type?custom_taxonomy=3"},{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/posts?custom_taxonomy=3"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]' 107 | http_version: 108 | recorded_at: Mon, 20 Feb 2017 22:16:45 GMT 109 | recorded_with: VCR 3.0.3 110 | -------------------------------------------------------------------------------- /spec/cassettes/4.7/single_user.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: http://localhost:8080/wp-json/wp/v2/users/1?_embed=true 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - Faraday v0.11.0 12 | Authorization: 13 | - OAuth oauth_consumer_key="DJyagPXmjMxO", oauth_nonce="ad8f5dd0ebd33516c81b8ce84126dd7d", 14 | oauth_signature="ZS9ftIClNhVMi7FJa5j%2BaAjzjfA%3D", oauth_signature_method="HMAC-SHA1", 15 | oauth_timestamp="1487629007", oauth_token="8w2Q6IJj63OB01FmNlu6WA5A", oauth_version="1.0" 16 | Expect: 17 | - '' 18 | response: 19 | status: 20 | code: 200 21 | message: OK 22 | headers: 23 | Host: 24 | - localhost:8080 25 | Connection: 26 | - close 27 | X-Powered-By: 28 | - PHP/5.6.26 29 | Content-Type: 30 | - application/json; charset=UTF-8 31 | X-Robots-Tag: 32 | - noindex 33 | Link: 34 | - ; rel="https://api.w.org/" 35 | X-Content-Type-Options: 36 | - nosniff 37 | Access-Control-Expose-Headers: 38 | - X-WP-Total, X-WP-TotalPages 39 | Access-Control-Allow-Headers: 40 | - Authorization, Content-Type 41 | Expires: 42 | - Wed, 11 Jan 1984 05:00:00 GMT 43 | Cache-Control: 44 | - no-cache, must-revalidate, max-age=0 45 | Last-Modified: 46 | - '' 47 | Allow: 48 | - GET, POST, PUT, PATCH, DELETE 49 | body: 50 | encoding: UTF-8 51 | string: '{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/localhost:8080\/author\/admin\/","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/927009d35360a64b8fb08bfddfe2f867?s=96&d=mm&r=g"},"meta":[],"_links":{"self":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/localhost:8080\/wp-json\/wp\/v2\/users"}]}}' 52 | http_version: 53 | recorded_at: Mon, 20 Feb 2017 22:16:47 GMT 54 | recorded_with: VCR 3.0.3 55 | -------------------------------------------------------------------------------- /spec/collection_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe WpApiClient::Collection do 2 | describe "fetching posts of a certain post type", vcr: {cassette_name: 'custom_post_type_collection', record: :new_episodes} do 3 | 4 | before :each do 5 | @collection = @api.get("custom_post_type") 6 | end 7 | 8 | it "returns an array of posts" do 9 | expect(@collection.first).to be_a WpApiClient::Entities::Post 10 | end 11 | 12 | it "can paginate" do 13 | expect(@collection.count).to eq 10 14 | paged_id = @collection.first.id 15 | 16 | @next_page = @api.get(@collection.next_page) 17 | expect(@next_page.first.id).to eq (paged_id - 10) 18 | 19 | @previous_page = @api.get(@next_page.previous_page) 20 | expect(@previous_page.first.id).to eq paged_id 21 | 22 | # no pages left to turn 23 | expect(@previous_page.previous_page).to eq nil 24 | end 25 | 26 | it "accepts array and non-array input" do 27 | single_post = @collection.first 28 | expect(single_post).not_to be_an Array 29 | 30 | expect { 31 | WpApiClient::Collection.new(single_post.resource) 32 | }.not_to raise_error 33 | end 34 | 35 | it "responds to array methods" do 36 | expect(@collection.count).to eq 10 37 | @collection.delete_at(0) # delete_at is Array-only 38 | expect(@collection.count).to eq 9 39 | end 40 | 41 | it "throws an error when it tries to parse an error response" do 42 | expect { 43 | WpApiClient::Collection.new([{"code"=>"rest_forbidden", "message"=>"You don't have permission to do this.", "data"=>{"status"=>403}}]) 44 | }.to raise_error 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /spec/connection_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe WpApiClient::Collection do 2 | describe "fetching posts concurrently", vcr: {cassette_name: 'concurrency', record: :new_episodes} do 3 | 4 | it "allows simultaneous fetching of posts" do 5 | resp = @api.concurrently do |api| 6 | api.get("posts/1") 7 | api.get("posts", page: 2) 8 | end 9 | expect(resp.first.title).to eq 'Hello world!' 10 | expect(resp.last.first.title).to eq 'Post 90' 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /spec/entity_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe WpApiClient::Entities::Base do 2 | describe "general entity methods", vcr: {cassette_name: 'single_post', record: :new_episodes} do 3 | 4 | it "work to retrieve embedded hypermedia" do 5 | WpApiClient.configure { |api_client| api_client.embed = true } 6 | 7 | # Posts offer terms as embedded hypermedia 8 | @post = WpApiClient.get_client.get('posts/1') 9 | expect(@post.terms("category")).to be_a WpApiClient::Collection 10 | end 11 | 12 | it "work to retrieve non-embedded hypermedia" do 13 | WpApiClient.configure { |api_client| api_client.embed = false } 14 | 15 | # Posts offer terms as embedded hypermedia 16 | @post = WpApiClient.get_client.get('posts/1') 17 | expect(@post.terms("category")).to be_a WpApiClient::Collection 18 | end 19 | 20 | it "allows querying on specific relations from posts to terms" do 21 | @post = @api.get('posts/1') 22 | category = @post.terms("category") 23 | 24 | expect(category).to be_a WpApiClient::Collection 25 | end 26 | 27 | it "allows querying on specific relations from terms to posts" do 28 | category = @api.get('categories/1') 29 | 30 | expect(category.posts("posts")).to be_a WpApiClient::Collection 31 | end 32 | 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /spec/error_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe WpApiClient::Entities::Error do 2 | describe "an API access error", vcr: {cassette_name: 'single_post'} do 3 | 4 | Error_JSON = {"code"=>"rest_forbidden", "message"=>"You don't have permission to do this.", "data"=>{"status"=>403}} 5 | 6 | it "throws an exception" do 7 | expect { 8 | WpApiClient::Entities::Error.new(Error_JSON) 9 | }.to raise_error(WpApiClient::ErrorResponse) 10 | end 11 | 12 | it "recognises the error JSON exception" do 13 | expect(WpApiClient::Entities::Error.represents?(Error_JSON)).to be_truthy 14 | end 15 | 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /spec/media_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe WpApiClient::Entities::Image do 2 | describe "calling instance methods on an image object", vcr: {cassette_name: 'single_image'} do 3 | 4 | before :each do 5 | @image = @api.get("media/203") 6 | end 7 | 8 | it "returns the URL for different sizes" do 9 | expect(@image.sizes(:thumbnail)).to be_a_url 10 | expect(@image.sizes(:full)).to be_a_url 11 | expect(@image.sizes(:not_a_real_size)).to be_nil 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /spec/post_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe WpApiClient::Entities::Post do 2 | describe "calling instance methods on a post", vcr: {cassette_name: 'single_post'} do 3 | 4 | before :each do 5 | @post = @api.get("posts/1") 6 | end 7 | 8 | it "returns the title" do 9 | expect(@post.title).to eq "Hello world!" 10 | end 11 | 12 | it "returns the date as a Time object" do 13 | expect(@post.date).to be_a Time 14 | end 15 | 16 | it "returns the content as HTML" do 17 | expect(@post.content).to eq "

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

\n" 18 | end 19 | 20 | it "returns its own ID" do 21 | expect(@post.id).to eq 1 22 | end 23 | 24 | it "returns its own slug" do 25 | expect(@post.slug).to eq 'hello-world' 26 | end 27 | 28 | it "allows its internal resource to be queried directly" do 29 | expect(@post.resource["slug"]).to eq 'hello-world' 30 | end 31 | 32 | it "returns its author" do 33 | expect(@post.author).to be_a WpApiClient::Entities::User 34 | end 35 | 36 | end 37 | 38 | describe "meta function" do 39 | 40 | before :all do 41 | WpApiClient.reset! 42 | oauth_credentials = get_test_oauth_credentials 43 | 44 | WpApiClient.configure do |api_client| 45 | api_client.oauth_credentials = oauth_credentials 46 | end 47 | @api = WpApiClient.get_client 48 | end 49 | 50 | after :all do 51 | WpApiClient.reset! 52 | end 53 | 54 | it "returns an individual meta value" do 55 | VCR.use_cassette('single_post_auth', record: :new_episodes) do 56 | @post = WpApiClient.get_client.get("posts/1") 57 | expect(@post.meta(:example_metadata_field)).to eq "example_meta_value" 58 | end 59 | end 60 | 61 | it "caches" do 62 | VCR.use_cassette('single_post_auth', record: :new_episodes) do 63 | @post = WpApiClient.get_client.get("posts/1") 64 | meta_value = @post.meta(:example_metadata_field) 65 | end 66 | VCR.turned_off do 67 | ::WebMock.disable_net_connect! 68 | expect { 69 | @post.meta(:example_associated_post_id) 70 | }.to_not raise_error 71 | end 72 | end 73 | 74 | it "returns the right items from cache" do 75 | VCR.use_cassette('single_post_auth', record: :new_episodes) do 76 | @post = WpApiClient.get_client.get("posts/1") 77 | expect(@post.meta(:example_metadata_field)).to eq "example_meta_value" 78 | expect(@post.meta(:example_associated_post_id)).to eq "100" 79 | end 80 | end 81 | end 82 | end 83 | -------------------------------------------------------------------------------- /spec/relationships_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe WpApiClient::Relationship do 2 | describe "relationships with terms", vcr: {cassette_name: 'single_post'} do 3 | before :each do 4 | post = @api.get("posts/1") 5 | @relationship = WpApiClient::Relationship.new(post.resource, "https://api.w.org/term") 6 | end 7 | 8 | it "presents term objects as a set of key/value collections" do 9 | relations = @relationship.get_relations 10 | expect(relations).to be_a Hash 11 | expect(relations["category"]).to be_a WpApiClient::Collection 12 | end 13 | end 14 | 15 | describe "relationships with posts", vcr: {cassette_name: 'single_term'} do 16 | before :each do 17 | term = @api.get("categories/1") 18 | @relationship = WpApiClient::Relationship.new(term.resource, "http://api.w.org/v2/post_type") 19 | end 20 | 21 | it "returns an collection of posts" do 22 | relations = @relationship.get_relations 23 | expect(relations).to be_a Hash 24 | expect(relations["posts"]).to be_a WpApiClient::Collection 25 | end 26 | end 27 | 28 | describe "relationships with featured images", vcr: {cassette_name: 'single_post'} do 29 | before :each do 30 | term = @api.get("posts/1") 31 | @relationship = WpApiClient::Relationship.new(term.resource, "https://api.w.org/featuredmedia") 32 | end 33 | 34 | it "returns an collection of posts" do 35 | relations = @relationship.get_relations 36 | expect(relations).to be_a WpApiClient::Collection 37 | expect(relations.first).to be_a WpApiClient::Entities::Image 38 | end 39 | end 40 | 41 | describe "relationships with metadata", vcr: {cassette_name: 'single_post_auth', record: :new_episodes} do 42 | before :each do 43 | # we need oAuth for this 44 | WpApiClient.reset! 45 | oauth_credentials = get_test_oauth_credentials 46 | WpApiClient.configure do |api_client| 47 | api_client.oauth_credentials = oauth_credentials 48 | end 49 | @api = WpApiClient.get_client 50 | post = @api.get("posts/1") 51 | @relationship = WpApiClient::Relationship.new(post.resource, "https://api.w.org/meta") 52 | end 53 | 54 | it "returns an hash of meta" do 55 | relations = @relationship.get_relations 56 | expect(relations).to be_a Hash 57 | expect(relations["example_metadata_field"]).to be_a String 58 | end 59 | end 60 | 61 | end 62 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | #$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) 2 | 3 | # This file was generated by the `rspec --init` command. Conventionally, all 4 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 5 | # The generated `.rspec` file contains `--require spec_helper` which will cause 6 | # this file to always be loaded, without a need to explicitly require it in any 7 | # files. 8 | # 9 | # Given that it is always loaded, you are encouraged to keep this file as 10 | # light-weight as possible. Requiring heavyweight dependencies from this file 11 | # will add to the boot time of your test suite on EVERY test run, even for an 12 | # individual file that may not need all of that loaded. Instead, consider making 13 | # a separate helper file that requires the additional dependencies and performs 14 | # the additional setup, and require it from the spec files that actually need 15 | # it. 16 | # 17 | # The `.rspec` file also contains a few flags that are not defaults but that 18 | # users commonly want. 19 | # 20 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 21 | # 22 | 23 | Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |f| require f } 24 | wp_version = ENV["WP_VERSION"] || "4.4" 25 | WPAPICLIENT_VCR_PATH = "spec/cassettes/#{wp_version}" 26 | 27 | require 'vcr' 28 | VCR.configure do |c| 29 | c.cassette_library_dir = WPAPICLIENT_VCR_PATH 30 | c.hook_into :webmock 31 | c.configure_rspec_metadata! 32 | end 33 | 34 | RSpec.configure do |config| 35 | 36 | config.before(:each) do 37 | WpApiClient.configure do |api_client| 38 | api_client.endpoint = 'http://localhost:8080/wp-json/wp/v2' 39 | end 40 | @api = WpApiClient.get_client 41 | end 42 | 43 | config.after(:each) do 44 | WpApiClient.reset 45 | end 46 | 47 | # rspec-expectations config goes here. You can use an alternate 48 | # assertion/expectation library such as wrong or the stdlib/minitest 49 | # assertions if you prefer. 50 | config.expect_with :rspec do |expectations| 51 | # This option will default to `true` in RSpec 4. It makes the `description` 52 | # and `failure_message` of custom matchers include text for helper methods 53 | # defined using `chain`, e.g.: 54 | # be_bigger_than(2).and_smaller_than(4).description 55 | # # => "be bigger than 2 and smaller than 4" 56 | # ...rather than: 57 | # # => "be bigger than 2" 58 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 59 | end 60 | 61 | # rspec-mocks config goes here. You can use an alternate test double 62 | # library (such as bogus or mocha) by changing the `mock_with` option here. 63 | config.mock_with :rspec do |mocks| 64 | # Prevents you from mocking or stubbing a method that does not exist on 65 | # a real object. This is generally recommended, and will default to 66 | # `true` in RSpec 4. 67 | mocks.verify_partial_doubles = true 68 | end 69 | 70 | # The settings below are suggested to provide a good initial experience 71 | # with RSpec, but feel free to customize to your heart's content. 72 | =begin 73 | # These two settings work together to allow you to limit a spec run 74 | # to individual examples or groups you care about by tagging them with 75 | # `:focus` metadata. When nothing is tagged with `:focus`, all examples 76 | # get run. 77 | config.filter_run :focus 78 | config.run_all_when_everything_filtered = true 79 | 80 | # Allows RSpec to persist some state between runs in order to support 81 | # the `--only-failures` and `--next-failure` CLI options. We recommend 82 | # you configure your source control system to ignore this file. 83 | config.example_status_persistence_file_path = "spec/examples.txt" 84 | 85 | # Limits the available syntax to the non-monkey patched syntax that is 86 | # recommended. For more details, see: 87 | # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ 88 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 89 | # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode 90 | config.disable_monkey_patching! 91 | 92 | # This setting enables warnings. It's recommended, but in some cases may 93 | # be too noisy due to issues in dependencies. 94 | config.warnings = true 95 | 96 | # Many RSpec users commonly either run the entire suite or an individual 97 | # file, and it's useful to allow more verbose output when running an 98 | # individual spec file. 99 | if config.files_to_run.one? 100 | # Use the documentation formatter for detailed output, 101 | # unless a formatter has already been configured 102 | # (e.g. via a command-line flag). 103 | config.default_formatter = 'doc' 104 | end 105 | 106 | # Print the 10 slowest examples and example groups at the 107 | # end of the spec run, to help surface which specs are running 108 | # particularly slow. 109 | config.profile_examples = 10 110 | 111 | # Run specs in random order to surface order dependencies. If you find an 112 | # order dependency and want to debug it, you can fix the order by providing 113 | # the seed, which is printed after each run. 114 | # --seed 1234 115 | config.order = :random 116 | 117 | # Seed global randomization in this process using the `--seed` CLI option. 118 | # Setting this allows you to use `--seed` to deterministically reproduce 119 | # test failures related to randomization by passing the same `--seed` value 120 | # as the one that triggered the failure. 121 | Kernel.srand config.seed 122 | =end 123 | end 124 | 125 | def get_test_oauth_credentials 126 | # These credentials were used to construct the VCR cassettes so they're needed to run the tests 127 | JSON.parse(File.read('config/test-oauth-credentials.json'), symbolize_names: true) 128 | end 129 | 130 | require 'wp_api_client' 131 | require 'json' 132 | -------------------------------------------------------------------------------- /spec/support/matchers.rb: -------------------------------------------------------------------------------- 1 | require 'rspec/expectations' 2 | 3 | RSpec::Matchers.define :be_a_url do |expected| 4 | match do |actual| 5 | URI.parse(actual) rescue false 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/taxonomy_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe WpApiClient::Entities::Taxonomy do 2 | describe "calling instance methods on a taxonomy", vcr: {cassette_name: 'single_taxonomy', record: :new_episodes} do 3 | 4 | before :each do 5 | @taxonomy = @api.get("taxonomies/custom_taxonomy") 6 | end 7 | 8 | it "returns the name" do 9 | expect(@taxonomy.name).to eq "Custom taxonomy" 10 | end 11 | 12 | it "returns a collection of terms" do 13 | expect(@taxonomy.terms.first.name).to be_a String 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /spec/term_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe WpApiClient::Entities::Term do 2 | describe "reading data out of the term", vcr: {cassette_name: 'single_term', record: :new_episodes} do 3 | 4 | before :each do 5 | @term = @api.get("categories/1") 6 | end 7 | 8 | it "returns the name" do 9 | expect(@term.name).to eq "Uncategorized" 10 | end 11 | 12 | it "returns the slug" do 13 | expect(@term.slug).to eq "uncategorized" 14 | end 15 | 16 | it "returns a taxonomy object" do 17 | expect(@term.taxonomy).to be_a WpApiClient::Entities::Taxonomy 18 | end 19 | 20 | end 21 | 22 | describe "a term connected to two different post types", vcr: {cassette_name: 'single_term', record: :new_episodes} do 23 | 24 | before :each do 25 | @term = @api.get("custom_taxonomy/2") 26 | end 27 | 28 | it "returns two collections of posts" do 29 | expect(@term.posts).to be_a Hash 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /spec/user_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe WpApiClient::Entities::User do 2 | describe "calling instance methods on a user", vcr: {cassette_name: 'single_user'} do 3 | before :each do 4 | @user = @api.get("users/1") 5 | end 6 | 7 | it "returns the id" do 8 | expect(@user.id).to eq 1 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/wp_api_client_spec.rb: -------------------------------------------------------------------------------- 1 | describe WpApiClient do 2 | it 'has a version number' do 3 | expect(WpApiClient::VERSION).not_to be nil 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /spec/wp_api_configuration_spec.rb: -------------------------------------------------------------------------------- 1 | require 'webmock/rspec' 2 | 3 | RSpec.describe WpApiClient::Configuration do 4 | describe "#configure" do 5 | 6 | before(:each) do 7 | WpApiClient.reset! 8 | end 9 | 10 | it "can set the endpoint URL for the API connection" do 11 | VCR.turned_off do 12 | 13 | imaginary_api_location = "http://example.com/wp-json/wp/v2" 14 | 15 | # get an example API response and mock it 16 | 17 | ::WebMock.stub_request(:get, 18 | imaginary_api_location + "/custom_post_type?_embed=true" 19 | ).to_return( 20 | body: example_response, 21 | headers: {'Content-Type' => 'application/json'} 22 | ) 23 | 24 | # Configure the API client to point somewhere else 25 | WpApiClient.configure do |api_client| 26 | api_client.endpoint = imaginary_api_location 27 | end 28 | WpApiClient.get_client.get('custom_post_type') 29 | end 30 | end 31 | 32 | it "can specify whether or not to request embedded resources" do 33 | VCR.turned_off do 34 | 35 | WpApiClient.configure do |api_client| 36 | api_client.embed = false 37 | end 38 | 39 | # get an example API response and mock it 40 | ::WebMock.stub_request(:get, 41 | WpApiClient.configuration.endpoint + "/posts/1" 42 | ).to_return( 43 | body: example_response, 44 | headers: {'Content-Type' => 'application/json'} 45 | ) 46 | 47 | post = WpApiClient.get_client.get('posts/1') 48 | end 49 | end 50 | 51 | it "can set up OAuth credentials", vcr: {cassette_name: :oauth_test} do 52 | oauth_credentials = get_test_oauth_credentials 53 | 54 | WpApiClient.configure do |api_client| 55 | api_client.oauth_credentials = oauth_credentials 56 | end 57 | 58 | WpApiClient.get_client.get('posts/1') 59 | end 60 | 61 | it "can set up link relationships", vcr: {cassette_name: :single_post} do 62 | WpApiClient.configure do |api_client| 63 | api_client.define_mapping("http://my.own/mapping", :post) 64 | end 65 | 66 | post = WpApiClient.get_client.get('posts/1') 67 | expect { post.relations("http://my.own/mapping") }.not_to raise_error 68 | end 69 | 70 | it "exposes a #proxy configuration option" do 71 | WpApiClient.configure do |api_client| 72 | api_client.proxy = "http://localhost:8080" 73 | end 74 | 75 | expect(WpApiClient.configuration.proxy).to eq "http://localhost:8080" 76 | end 77 | end 78 | 79 | private 80 | 81 | def example_response 82 | YAML.load(File.read WPAPICLIENT_VCR_PATH + '/custom_post_type_collection.yml')['http_interactions'][0]['response']['body']['string'] 83 | end 84 | 85 | 86 | end 87 | -------------------------------------------------------------------------------- /wp_api_client.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'wp_api_client/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "wp-api-client" 8 | spec.version = WpApiClient::VERSION 9 | spec.authors = ["Duncan Brown"] 10 | spec.email = ["duncanjbrown@gmail.com"] 11 | 12 | spec.summary = %q{A read-only client for the WordPress REST API (v2).} 13 | spec.homepage = "https://github.com/duncanjbrown/wp-api-client" 14 | spec.license = "MIT" 15 | 16 | # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or 17 | # delete this section to allow pushing this gem to any host. 18 | if spec.respond_to?(:metadata) 19 | spec.metadata['allowed_push_host'] = "https://rubygems.org" 20 | else 21 | raise "RubyGems 2.0 or newer is required to protect against public gem pushes." 22 | end 23 | 24 | spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } 25 | spec.bindir = "exe" 26 | spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } 27 | spec.require_paths = ["lib"] 28 | 29 | spec.required_ruby_version = '~> 2.3' 30 | 31 | spec.add_dependency "faraday", "~> 0.9" 32 | spec.add_dependency "faraday_middleware", "~> 0.10" 33 | spec.add_dependency "faraday-http-cache", "~> 1.2" 34 | spec.add_dependency "simple_oauth", "~> 0.3" 35 | spec.add_dependency "typhoeus", "~> 1.0" 36 | 37 | spec.add_development_dependency "bundler", "~> 1.11" 38 | spec.add_development_dependency "rake", "~> 10.0" 39 | spec.add_development_dependency "rspec", "~> 3.0" 40 | spec.add_development_dependency "vcr", "~> 3" 41 | spec.add_development_dependency "webmock", "~> 3" 42 | end 43 | --------------------------------------------------------------------------------