Code Duplication    Length = 53-56 lines in 2 locations

includes/api/class-wc-rest-product-attributes-controller.php 1 location

@@ 518-570 (lines=53) @@
515
	 *
516
	 * @return array
517
	 */
518
	public function get_item_schema() {
519
		$schema = array(
520
			'$schema'              => 'http://json-schema.org/draft-04/schema#',
521
			'title'                => 'product_attribute',
522
			'type'                 => 'object',
523
			'properties'           => array(
524
				'id' => array(
525
					'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
526
					'type'        => 'integer',
527
					'context'     => array( 'view', 'edit' ),
528
					'readonly'    => true,
529
				),
530
				'name' => array(
531
					'description' => __( 'Attribute name.', 'woocommerce' ),
532
					'type'        => 'string',
533
					'context'     => array( 'view', 'edit' ),
534
					'arg_options' => array(
535
						'sanitize_callback' => 'sanitize_text_field',
536
					),
537
				),
538
				'slug' => array(
539
					'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ),
540
					'type'        => 'string',
541
					'context'     => array( 'view', 'edit' ),
542
					'arg_options' => array(
543
						'sanitize_callback' => 'sanitize_title',
544
					),
545
				),
546
				'type' => array(
547
					'description' => __( 'Type of attribute.', 'woocommerce' ),
548
					'type'        => 'string',
549
					'default'     => 'select',
550
					'enum'        => array_keys( wc_get_attribute_types() ),
551
					'context'     => array( 'view', 'edit' ),
552
				),
553
				'order_by' => array(
554
					'description' => __( 'Default sort order.', 'woocommerce' ),
555
					'type'        => 'string',
556
					'default'     => 'menu_order',
557
					'enum'        => array( 'menu_order', 'name', 'name_num', 'id' ),
558
					'context'     => array( 'view', 'edit' ),
559
				),
560
				'has_archives' => array(
561
					'description' => __( 'Enable/Disable attribute archives.', 'woocommerce' ),
562
					'type'        => 'boolean',
563
					'default'     => false,
564
					'context'     => array( 'view', 'edit' ),
565
				),
566
			),
567
		);
568
569
		return $this->add_additional_fields_schema( $schema );
570
	}
571
572
	/**
573
	 * Get the query params for collections

includes/api/class-wc-rest-shipping-zone-methods-controller.php 1 location

@@ 379-434 (lines=56) @@
376
	 *
377
	 * @return array
378
	 */
379
	public function get_item_schema() {
380
		$schema = array(
381
			'$schema'    => 'http://json-schema.org/draft-04/schema#',
382
			'title'      => 'shipping_zone_method',
383
			'type'       => 'object',
384
			'properties' => array(
385
				'instance_id' => array(
386
					'description' => __( 'Shipping method instance ID.', 'woocommerce' ),
387
					'type'        => 'integer',
388
					'context'     => array( 'view' ),
389
				),
390
				'title' => array(
391
					'description' => __( 'Shipping method customer facing title.', 'woocommerce' ),
392
					'type'        => 'string',
393
					'context'     => array( 'view' ),
394
				),
395
				'order' => array(
396
					'description' => __( 'Shipping method sort order.', 'woocommerce' ),
397
					'type'        => 'integer',
398
					'context'     => array( 'view', 'edit' ),
399
					'required'    => false,
400
					'arg_options' => array(
401
						'sanitize_callback' => 'absint',
402
					),
403
				),
404
				'enabled' => array(
405
					'description' => __( 'Shipping method enabled status.', 'woocommerce' ),
406
					'type'        => 'boolean',
407
					'context'     => array( 'view', 'edit' ),
408
					'required'    => false,
409
				),
410
				'method_id' => array(
411
					'description' => __( 'Shipping method ID. Write on create only.', 'woocommerce' ),
412
					'type'        => 'string',
413
					'context'     => array( 'view', 'edit.' ),
414
				),
415
				'method_title' => array(
416
					'description' => __( 'Shipping method title.', 'woocommerce' ),
417
					'type'        => 'string',
418
					'context'     => array( 'view' ),
419
				),
420
				'method_description' => array(
421
					'description' => __( 'Shipping method description.', 'woocommerce' ),
422
					'type'        => 'string',
423
					'context'     => array( 'view' ),
424
				),
425
				'settings' => array(
426
					'description' => __( 'Shipping method settings.', 'woocommerce' ),
427
					'type'        => 'array',
428
					'context'     => array( 'view', 'edit' ),
429
				),
430
			),
431
		);
432
433
		return $this->add_additional_fields_schema( $schema );
434
	}
435
}
436